Java android新手需要了解“?android:attr/actionBarSize”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20773307/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
New to android need to understand "?android:attr/actionBarSize"
提问by user3134565
I was going through Lars Vogel's tutorialon using Fragments and I came across the following code:
我正在阅读Lars Vogel关于使用 Fragments的教程,我遇到了以下代码:
android:layout_marginTop="?android:attr/actionBarSize"
I am not sure what ?android:attr
means, especially the question mark.
我不确定是什么?android:attr
意思,尤其是问号。
采纳答案by Phant?maxx
android:attr
is an attribute.
是一个属性。
In specific,
具体来说,
android:layout_marginTop="?android:attr/actionBarSize"
means: "the size (height) of the action bar".
?is a special character that means it's an Android internal feature.
意思是:“操作栏的大小(高度)”。
? 是一个特殊字符,表示它是 Android 内部功能。
回答by Aniruddha Sarkar
While building android apps, one requires to know the properties of the Android client. Such as screen size etc. One such method is by using android:attr
which is android attributes. Here you have mentioned to return a specific attribute by mentioning the keyword after / symbol. Here the keyword is actionBarSize
.
在构建Android应用程序时,需要了解Android客户端的属性。例如屏幕大小等。一种这样的方法是使用android:attr
android 属性。在这里,您提到通过在 / 符号后提及关键字来返回特定属性。这里的关键字是actionBarSize
。
The ?
symbol is an operator which is used to access system configurations and properties in Android
的?
符号是用于访问系统配置和性能Android中的操作者
回答by ahmed hamdy
Instead of write Numerical number in value of android:layout_marginTop
, you can use the height specified by actionBarSize like an Example in Android Training .
android:layout_marginTop
您可以像Android Training 中的示例一样使用actionBarSize指定的高度,而不是在 的值中写入数值。
You can use ?android:attr
or ?attr
[ in case support library ] If you need to use any android attributes[ attr
] can be found in R.attr
您可以使用 ?android:attr
或?attr
[如果支持库] 如果您需要使用任何 android 属性 [ attr
] 可以在R.attr 中找到