Advertisement
shishir123

Android_Custom_text_on_actionbar

May 13th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1.     public void formatTitle(){
  2.         TextView tv = new TextView(getApplicationContext());
  3.         ActionBar.LayoutParams lp = new ActionBar.LayoutParams(
  4.                 ActionBar.LayoutParams.MATCH_PARENT, // Width of TextView
  5.                 ActionBar.LayoutParams.WRAP_CONTENT); // Height of TextView
  6.         tv.setLayoutParams(lp);
  7.         tv.setText(actionBar.getTitle()); // ActionBar title text
  8.         tv.setTextColor(Color.WHITE);
  9.         tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP,18);
  10.         actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
  11.         actionBar.setCustomView(tv);
  12.         actionBar.setDisplayShowHomeEnabled(true);
  13.         actionBar.setDisplayHomeAsUpEnabled(true);
  14.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement