android - ActionBar的大小(以像素为单位)是多少?
我需要知道ActionBar的确切大小(以像素为单位),以便应用正确的背景图像。
13个解决方案
499 votes
要在XML中检索ActionBar的高度,只需使用
?android:attr/actionBarSize
或者如果您是ActionBarSherlock或AppCompat用户,请使用此选项
?attr/actionBarSize
如果在运行时需要此值,请使用此值
final TypedArray styledAttributes = getContext().getTheme().obtainStyledAttributes(
new int[] { android.R.attr.actionBarSize });
mActionBarSize = (int) styledAttributes.getDimension(0, 0);
styledAttributes.recycle();
如果您需要了解定义的位置:
属性名称本身在平台的/res/values/attrs.xml中定义
平台的themes.xml选择此属性并为其分配值。
步骤2中分配的值取决于不同的设备大小,这些大小在平台中的各种dimens.xml文件中定义,即。芯/ RES / RES /值-sw600dp/ dimens.xml
AZ13 answered 2019-02-21T08:18:18Z
50 votes
从Android 3.2的framework-res.apk的解编译来源,res/values/styles.xml包含: