如何设置标题栏的背景?
问题描述:
我按照说明书从这个SO问题:How to change the text on the action bar如何设置标题栏的背景?
我能够成功地创建自己的标题栏,但是当我申请一个背景颜色到我的布局,颜色不整个标题栏跨越。仍然存在Android灰色背景色的残余。
这里是我的XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="400px"
android:layout_height="fill_parent"
android:orientation="horizontal" android:background="@color/solid_blue">
<ImageView android:id="@+id/logo"
android:layout_width="57px"
android:layout_height="wrap_content"
android:background="@drawable/icon">
</ImageView>
<TextView
android:id="@+id/myTitle"
android:text="StockDroid by"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="#FFFFFF"
/>
</LinearLayout>
答
编辑:
你已经错过了设置自定义样式的窗口标题,并由android:theme
属性为活动设置在清单中的东西。
你有你的RES /价值/ styles.xml文件创建此两个样式:
<style name="MyTheme" parent="android:Theme">
<item name="android:windowTitleSize">50px</item>
<item name="android:windowTitleBackgroundStyle">@style/WindowTitleBackground
</item>
</style>
<style name="WindowTitleBackground" parent="android:WindowTitleBackground">
<item name="android:background">@android:color/transparent
</item>
</style>
那么你必须设置你的主题风格你显明是这样的:
<activity android:name=".activity"
android:label="@string/appname" android:theme="@style/MyTheme" />
希望它有帮助。