其他分享
首页 > 其他分享> > 什么是TitleBar的默认高度和Android中Titlebar中的默认TextSize?

什么是TitleBar的默认高度和Android中Titlebar中的默认TextSize?

作者:互联网

有谁知道android中TitleBar和TitleBarText的默认大小是多少?

解决方法:

您可以在此处找到默认高度

http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.3_r1/frameworks/base/core/res/res/values/dimens.xml

以下是4.0.3

<dimen name="action_bar_default_height">48dip</dimen>
<dimen name="action_bar_title_text_size">18dp</dimen>

检查各个res / values文件夹下的dimens.xml

来自Gopal Rao的评论

http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.3_r1/frameworks/base/core/res/res/values/styles.xml?av=f

<style name="TextAppearance">
        <item name="android:textColor">?textColorPrimary</item>
        <item name="android:textColorHighlight">?textColorHighlight</item>
        <item name="android:textColorHint">?textColorHint</item>
        <item name="android:textColorLink">?textColorLink</item>
        <item name="android:textSize">16sp</item> // its is in sp not dp 
        <item name="android:textStyle">normal</item>
    </style>

http://developer.android.com/guide/practices/screens_support.html

如果你看一下主题最佳实践.

Quoting “you should prefer the sp (scale-independent pixel) to
define text sizes. The sp scale factor depends on a user setting and
the system scales the size the same as it does for dp”.

标签:android,android-titlebar
来源: https://codeday.me/bug/20190629/1323467.html