Eug*_*ene 254 android android-actionbar
我需要知道ActionBar的确切大小(以像素为单位),以便应用正确的背景图像.
AZ1*_*Z13 542
要在XML中检索ActionBar的高度,只需使用
?android:attr/actionBarSize
Run Code Online (Sandbox Code Playgroud)
或者如果您是ActionBarSherlock或AppCompat用户,请使用此选项
?attr/actionBarSize
Run Code Online (Sandbox Code Playgroud)
如果在运行时需要此值,请使用此值
final TypedArray styledAttributes = getContext().getTheme().obtainStyledAttributes(
new int[] { android.R.attr.actionBarSize });
mActionBarSize = (int) styledAttributes.getDimension(0, 0);
styledAttributes.recycle();
Run Code Online (Sandbox Code Playgroud)
如果您需要了解定义的位置:
Jak*_*ton 55
从Android 3.2的解压缩源framework-res.apk,res/values/styles.xml包含:
<style name="Theme.Holo">
<!-- ... -->
<item name="actionBarSize">56.0dip</item>
<!-- ... -->
</style>
Run Code Online (Sandbox Code Playgroud)
3.0和3.1似乎是相同的(至少来自AOSP)......
Dav*_*oho 43
要获取Actionbar的实际高度,您必须actionBarSize在运行时解析该属性.
TypedValue tv = new TypedValue();
context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true);
int actionBarHeight = getResources().getDimensionPixelSize(tv.resourceId);
Run Code Online (Sandbox Code Playgroud)
Vik*_*rla 33
其中一个蜂窝样品指的是 ?android:attr/actionBarSize
fla*_*rix 17
如果您使用的是最近的v7 appcompat支持包中的兼容性ActionBar,则可以使用高度获取高度
@dimen/abc_action_bar_default_height
Run Code Online (Sandbox Code Playgroud)
MrM*_*fen 16
使用新的v7支持库(21.0.0),名称R.dimen已更改为@ dimen/abc_action_bar_default_height_ material.
从早期版本的支持库升级时,您应该使用该值作为操作栏的高度
如果您使用的是ActionBarSherlock,则可以获得高度
@dimen/abs__action_bar_default_height
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
204472 次 |
| 最近记录: |