Android:动作栏样式
我想让动作栏像图片一样,但我不知道怎么做。制作这种类型的动作条的任何帮助都将非常有用,特别是活动标题与背景一起的部分Android:动作栏样式,android,android-actionbar,Android,Android Actionbar,我想让动作栏像图片一样,但我不知道怎么做。制作这种类型的动作条的任何帮助都将非常有用,特别是活动标题与背景一起的部分 要使标题成为您自己的自定义图像,您可以设置自定义布局 getActionBar().setCustomView(R.layout.my_title_layout); 其中R.layout.my_title_layout是标题的布局,带有背景和文本 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmln
要使标题成为您自己的自定义图像,您可以设置自定义布局
getActionBar().setCustomView(R.layout.my_title_layout);
其中R.layout.my_title_layout是标题的布局,带有背景和文本
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center">
<TextView
android:id="@+id/mytext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/app_name"
android:textColor="@color/black"
android:textSize="22sp"
android:background="@drawable/title_background"/>
</LinearLayout>
这将使其居中,您可以通过一个我命名为title\u background的可绘制形状设置背景:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/pink"/>
<stroke android:width="1dip" android:color="@color/pink" />
<corners android:radius="20dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
要设置字体,您需要自定义视图或放大布局。我无法理解“标题是您自己的自定义图像,您可以设置自定义视图”,以及如何将其放置在操作栏的中心?我将在一秒钟内编写一个示例,它不起作用。。看到我的这个问题了吗