To show multiple lines of title in Android ActionBar, one of the most common solution is to assign some of the text in SubTitle. Here we have another approach:
Basically we get the TextView object of the title in ActionBar, set it's max lines attribute to 2:
int titleId = Resources.getSystem().getIdentifier("action_bar_title","id","android");
TextView title = (TextView) findViewById(titleId);
title.setSingleLine(false);
title.setMaxLines(2);
title.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
Then we can set a long title to the ActionBar where the text will be displayed as two lines:
getActionBar().setTitle("... your long title here ...");
No comments:
Post a Comment