40

I was going through Lars Vogel's tutorial on using Fragments and I came across the following code:

android:layout_marginTop="?android:attr/actionBarSize"

I am not sure what ?android:attr means, especially the question mark.

Paul Chu
  • 1,249
  • 3
  • 19
  • 27
user3134565
  • 965
  • 1
  • 7
  • 14

3 Answers3

53
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.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
12

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 .

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

For More Description about ?android:attr Question 1 ,Question 2

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
ahmed hamdy
  • 5,096
  • 1
  • 47
  • 58
2

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.

The ? symbol is an operator which is used to access system configurations and properties in Android

Veger
  • 37,240
  • 11
  • 105
  • 116