Yogie Soesanto
Yogie Soesanto

Reputation: 172

Action Bar's Title Text Size in Android

do any of you know how to get the Text Size in Action Bar's Title

i know we can get ActionBar in android by using this code

ActionBar ab = getActionBar();

and we can change the Title of that ActionBar by using this code

ab.setTitle("This is Title");

Note : I dont want to Change the TextSize in ActionBar's Title , as i can do that by manipulating the XML and using Custom Action Bar. I just want to Know the TextSize of that ActionBar's Title

I assumed ActionBar use TextView inside it for the Title

and i really want to know if any of you know how to get the TextView from ActionBar's Title

or at least, know how to get the TextView's TextSize from ActionBar's Title

Upvotes: 0

Views: 2960

Answers (3)

Pankaj Arora
Pankaj Arora

Reputation: 10274

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);

Upvotes: 1

Spring Breaker
Spring Breaker

Reputation: 8251

You can see the dimens.xml file of the appcompat library where text size is defined for the ActionBar title.

 <!-- Text size for action bar titles -->
    <dimen name="abc_action_bar_title_text_size">18dp</dimen>

Upvotes: 2

Yogie Soesanto
Yogie Soesanto

Reputation: 172

big thanks for @shayan pourvatan

this is the code that help me

int actionBarTitleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
if (actionBarTitleId > 0) {
    TextView title = (TextView) findViewById(actionBarTitleId);
    if (title != null) {
        //pretty much i can do anything after i got this TextView
    }
}

Upvotes: 2

Related Questions