wawanopoulos
wawanopoulos

Reputation: 9802

Add a thin line on the top of Action bar Android

I would like to add a thin line with purple color at the top of my action bar like this :

enter image description here

UPDATE

Here is the code of my theme.xml :

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <style name="MyTheme" parent="@android:style/Theme.Holo.Light">
        <item name="android:actionBarStyle">@style/MyActionBar</item>
    </style>

    <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
        <item name="android:background">#00000000</item>
        <item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
    </style>

    <style name="MyActionBarTitleText">
        <item name="android:textSize">19sp</item>
        <item name="android:textColor">@color/relativeLayoutBg</item>
        <item name="android:gravity">center</item>
    </style>

</resources>

How can i do this ?

Upvotes: 1

Views: 494

Answers (1)

Tristan Burnside
Tristan Burnside

Reputation: 2566

You can use setBackgroundDrawable on the actionBar.

You can create a 9-patch drawable that will stretch out to look like that. http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch

EDIT:To set this in xml in styles.xml add

to the app theme add

<item name="android:actionBarStyle">@style/MyActionBarStyle</item>

and below add

<style name="MyActionBarStyle" parent="android:style/Widget.ActionBar">
<item name="android:background">@drawable/my_action_bar_background</item>
</style>

Upvotes: 1

Related Questions