What is the Default ActionBar Title Font Size?

后端 未结 2 587
情话喂你
情话喂你 2020-12-04 20:29

Seems to be 17dip. Just want to confirm it if anyone knows the exact size.

相关标签:
2条回答
  • 2020-12-04 21:23

    The short one…

    $ grep ActionBar platforms/android-11/data/res/values/* leads to

    styles.xml:

    <style name="TextAppearance.Widget.ActionBar.Title"
           parent="@android:style/TextAppearance.Medium">
    </style>
    
    <style name="TextAppearance.Widget.ActionBar.Subtitle"
           parent="@android:style/TextAppearance.Small">
    </style>
    
    […]
    
    <style name="TextAppearance.Medium">
        <item name="android:textSize">18sp</item>
    </style>
    
    <style name="TextAppearance.Small">
        <item name="android:textSize">14sp</item>
        <item name="android:textColor">?textColorSecondary</item>
    </style>
    
    0 讨论(0)
  • 2020-12-04 21:32

    This works for me.

    This is what I do to get the default toolbar style:

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.v7.widget.Toolbar
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/toolbar_top"
        android:layout_width="match_parent"
        android:layout_height="?actionBarSize"
        android:background="@color/primary_dark">
    
        <TextView
            android:id="@+id/toolbar_title"
            style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    
    </android.support.v7.widget.Toolbar>
    

    This does the trick to keep the default style style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"

    Then in your activity, you can do:

    Toolbar toolbarTop = (Toolbar) findViewById(R.id.toolbar_top);
    TextView mTitle = (TextView) toolbarTop.findViewById(R.id.toolbar_title);
    mTitle.setText("Custom...");
    
    0 讨论(0)
提交回复
热议问题