How to customize the Action Bar subtitle Font?

前端 未结 1 1716
有刺的猬
有刺的猬 2021-02-04 03:46

I have created an ActionBar (android.support.v7.widget.Toolbar) as below.



        
1条回答
  •  生来不讨喜
    2021-02-04 04:36

    If you don't already have this namespace attribute in your layout file add it:

    xmlns:app="http://schemas.android.com/apk/res-auto"

    Update your Toolbar attributes in your layout file like this:

    
    
    

    Add styles like these:

    
    
    
    

    Comments on this answer discuss whether the units for textSize should be dp or sp. When I originally wrote this answer, I looked at the Android source files and saw that dp was used. I recommend staying with that. As FrancescoDonzello explains in his comment, the size of the Toolbar is fixed and, unlike other widgets, will not expand to contain text enlarged by changes to the phone settings.

    0 讨论(0)
提交回复
热议问题