Wednesday, November 6, 2013

How To Change Text Color And Back Ground Color Of Action Bar In Android.

Text Color:-
according to my knowledge,the id of Action Bar Title id hidden,first you have to get id of that Acton Bar Title like:-

int ActionBarTitleID = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
 now use settext on this ID like 
TextView yourTextView = (TextView)findViewById(ActionBarTitleID); yourTextView.setTextColor(colorId);



If you use 
Sherlock Actionbar you may use the sherlock-actionbar-id for supported actionbars (Android below 3.0)

int titleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android"); 
if ( 0 == titleId ) titleId = com.actionbarsherlock.R.id.abs__action_bar_title;



Back Ground Color:-

mActionBar.setBackgroundDrawable(new ColorDrawable(0xff00DDED)); mActionBar.setDisplayShowTitleEnabled(false);

 mActionBar.setDisplayShowTitleEnabled(true);

No comments:

Post a Comment