Reputation: 23
I have just started using the action bar sherlock, and I have been struggling solving the border shown at the bottom of my action bar.. I am pretty sure the problem isn't caused by the background image..
<style name="Theme.MyTheme" parent="@style/Theme.Sherlock.Light">
<item name="actionBarStyle">@style/Widget.MyTheme.ActionBar</item>
<item name="android:actionBarStyle">@style/Widget.MyTheme.ActionBar</item>
<item name="android:actionBarItemBackground">@drawable/states_of_actionbar</item>
<item name="actionBarItemBackground">@drawable/states_of_actionbar</item>
<item name="actionDropDownStyle">@style/DropDownStyle</item>
<item name="android:actionDropDownStyle">@style/DropDownStyle</item>
</style>
<style name="Widget.MyTheme.ActionBar" parent="android:Widget.Holo.ActionBar">
<item name="android:background">@drawable/action_bar_bg</item>
<item name="background">@drawable/action_bar_bg</item>
<item name="android:src">@drawable/action_bar_bg</item>
</style>
I tried to define the above style (background) in values & values-14, but without luck..
My guess is that it is affected by holo style..
How can I get rid of the thick border?
Here is the image to clarify my problem:
Upvotes: 2
Views: 2834
Reputation: 1144
I think you try to using XY repeated background image or tiling as Action Bar background, so the problem is your background image is not height enough to cover Action Bar height and that thick border is as result of next Y tiling image.
You can fix this by increasing your image height.
Or you can use method of setTileModeXY(TileMode.REPEAT, TileMode.CLAMP)
from class android.graphics.drawable.BitmapDrawable
to make the image stretch its height while image being repeated horizontaly, then applied as your actionbar background.
Here the sample code :
void onCreate(Bundle savedInstanceState) {
BitmapDrawable bg = (BitmapDrawable)getResources().getDrawable(R.drawable.your_image); // get the image as bitmap drawable
bg.setTileModeXY(TileMode.REPEAT, TileMode.CLAMP); // set the TileMode.
getSupportActionBar().setBackgroundDrawable(bg); // applied to actionbar
}
Upvotes: 2