Reputation: 3050
All I want to do is a ActionBar with white background and a 1px red border at bottom. How can I achieve this?
Note: I have tried using 9-patch but red line always had some gradient BUT I don't want any gradient. Here is my 9-patch (T:Transparent, B:Black, W:White, R:Red):
TBT
BWB
TRT
TBT
As a best practice, should I define a separate xml that includes two rectangle shapes?
Upvotes: 1
Views: 344
Reputation: 6892
You don't need a nine-patch for that. You can just define a drawable in XML, like this:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#FF0000" />
</shape>
</item>
<item android:bottom="2dp">
<shape android:shape="rectangle">
<solid android:color="#FFFFFF" />
</shape>
</item>
</layer-list>
Then just use getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.mydrawable));
Upvotes: 1