I have followed the instructions from this SO question: How to change the text on the action bar
I am able to successfully create my own titlebar, however when I apply a background color to my layout, the color doesn't span across the entire titlebar. There are still remnants of the android gray background color.
Here is my XML:
<?xml version="1.0" encoding="utf-8"?>
<Linear开发者_如何学GoLayout 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>
Remaining stuff is on that link itself as a comment man.
Edit:
The stuff you have missed to set the custom style for the Window Title and set it at the Manifest by the android:theme
attribute for the activity.
you have to create this two style in your res/values/styles.xml file:
<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>
then you have to set you style as theme in you Manifest that is like:
<activity android:name=".activity"
android:label="@string/appname" android:theme="@style/MyTheme" />
hope it helps.
精彩评论