Tuesday 15 January 2013

image - Setting a background drawabe for actionbar in android -


I need to set different background image for the action bar for different pieces. I am using the v4 support package But I'm getting a white background instead of the given image.

Below is the code I used.

  getActivity () GetActionBar () SetBackgroundDrawable (getActivity (.) .getResources () getDrawable (R.id.image));   

Anything else

  bitmap beamap = bitmapfinder. Acida resources (getResources (), R.drawable.image); BitmapDrawable ActionBarbackground = new Bitmapdraw (getResources (), Bmap); ActionBar Bar = getActivity () GetActionBar (); Bar.setBackgroundDrawable (actionBarBackground);   

I have created this style and have used it in the manifest for activity

  android: theme = "@ style / ActionBarTheme" & lt ; Style name = "MyActionBar" parent = "@Android: style / widget.Holo. Actionbara" & gt; & Lt; Item name = "Android: Background" & gt; @photo_image & lt; / Item & gt; & Lt; / Style & gt; & Lt; Style name = "actionbeartheme" parent = "@ android: style / theme. Hollow. Light" & gt; & Lt; Item name = "Android: Actionbarstyle" & gt; @ Style / myactionbar & lt; / Item & gt; & Lt; / Style & gt;    

Try this one

  getActivity () . GetActionBar () setBackgroundDrawable (getActivity () getResources () getDrawable (R.drawable.image).);    

No comments:

Post a Comment