1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > Android:自定义标题栏

Android:自定义标题栏

时间:2021-05-09 12:13:59

相关推荐

Android:自定义标题栏

现在很多的Android程序都在标题栏上都显示了一些按钮和标题,这里尝试做个实例

在onCreate中添加:

//自定义标题requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);setContentView(R.layout.main);//设置标题为某个layoutgetWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar);

布局文件:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="/apk/res/android"android:layout_width="fill_parent"android:layout_height="wrap_content"android:orientation="horizontal"><Buttonandroid:id="@+id/back"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="上一步"android:textSize="18sp"/><TextViewandroid:layout_width="0dp"android:layout_weight="1"android:layout_height="wrap_content"android:text="标题"android:textSize="18sp"android:gravity="center"/><Buttonandroid:id="@+id/back"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="下一步"android:textSize="18sp"/></LinearLayout>

为避免冲突,修改:AndroidManifest.xml

android:theme="@style/mystyle"

style

<style name="mystyle" parent="android:Theme"><item name="android:windowTitleSize">50dp</item></style>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。