To customize the Android Title bar you need to define custom styles and apply those styles to a custom theme.
Under the folder "Values" create your "styles.xml" file.
Under the folder "Values" create your "styles.xml" file.
<?xml version="1.0" encoding="utf-8"?><resources>
<!-- Changing the text style of title bar-->
<style name="CustomTitleBarText" parent="android:TextAppearance.WindowTitle">
<item name="android:textSize">18dip</item>
<item name="android:textColor">#FFFFFF</item>
<item name="android:textStyle">bold</item>
</style>
<!-- Changes the background color of the title bar -->
<style name="CustomTitleBarBackground">
<item name="android:background">#555555</item>
</style>
<!-- Set the theme for the window title -->
<!-- NOTE: setting android:textAppearence to style defined above -->
<style name="CustomTitleBar" parent="android:WindowTitle">
<item name="android:textAppearance">@style/CustomTitleBarText</item>
<item name="android:shadowDx">0</item>
<item name="android:shadowDy">0</item>
<item name="android:shadowRadius">5</item>
<item name="android:shadowColor">#ffffff</item>
</style>
<!-- Override properties in the default theme -->
<!-- NOTE: you have to explicitly the windowTitleSize property,the title bar will not re-size automatically -->
<style name="CustomTheme" parent="android:Theme">
<item name="android:windowTitleSize">40dip</item>
<item name="android:windowTitleStyle">@style/CustomTitleBar</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomTitleBarBackground</item>
</style>
</resources>
After, you have to update your Manifest file and to set the new theme for your activity:
<activity android:name="HelloActivity" android:label="@string/CustomizedTitleBar" android:theme="@style/CustomTheme">
Very usuful, thanks
ReplyDeletethanks bro from France ;-)
ReplyDelete