@ And? In the xml file of Android? Difference

Source: Internet
Author: User

@ Everyone is familiar with it. For example, @ + id/... @ string /...

See the following code:


[Html]
<ProgressBar
Android: id = "@ + id/firstProgressBar"
Style = "? Android: progressBarStyleHorizontal"
Android: layout_width = "200dp"
Android: layout_height = "wrap_content"
Android: visibility = "gone"/>

<ProgressBar
Android: id = "@ + id/firstProgressBar"
Style = "? Android: progressBarStyleHorizontal"
Android: layout_width = "200dp"
Android: layout_height = "wrap_content"
Android: visibility = "gone"/>
The above Code uses "?", Then "?" What does that mean?

"?" Reference topic attributes. When you use this tag, the resource name you provide must be located in the topic attributes, because the resource tool considers this resource attribute to be expected, you do not need to explicitly specify its type (that is, in which file you do not need to write all of it? Android: attr/android: textDisabledColor)

So what is theme attribute?

You can find the attrs. xml file in the following directory of the Android SDK

D: \ android-sdk \ platforms \ android-16 \ data \ res \ values

Open this file and you can see that the attributes of the Android system are defined in this file.

For example (ImageView ):

[Html]
<Declare-styleable name = "ImageView">
<! -- Sets a drawable as the content of this ImageView. -->
<Attr name = "src" format = "reference | color"/>
<! -- Controls how the image shocould be resized or moved to match the size
Of this ImageView. -->
<Attr name = "scaleType">
<Enum name = "matrix" value = "0"/>
<Enum name = "fitXY" value = "1"/>
<Enum name = "fitStart" value = "2"/>
<Enum name = "fitCenter" value = "3"/>
<Enum name = "fitEnd" value = "4"/>
<Enum name = "center" value = "5"/>
<Enum name = "centerCrop" value = "6"/>
<Enum name = "centerInside" value = "7"/>
</Attr>
<! -- Set this to true if you want the ImageView to adjust its bounds
To preserve the aspect ratio of its drawable. -->
<Attr name = "adjustViewBounds" format = "boolean"/>
<! -- An optional argument to supply a maximum width for this view.
See {see android. widget. ImageView # setMaxWidth} for details. -->
<Attr name = "maxWidth" format = "dimension"/>
<! -- An optional argument to supply a maximum height for this view.
See {see android. widget. ImageView # setMaxHeight} for details. -->
<Attr name = "maxHeight" format = "dimension"/>
<! -- Set a tinting color for the image -->
<Attr name = "tint" format = "color"/>
<! -- If true, the image view will be baseline aligned with based on its
Bottom edge -->
<Attr name = "baselineAlignBottom" format = "boolean"/>
<! -- If true, the image will be cropped to fit within its padding -->
<Attr name = "cropToPadding" format = "boolean"/>
</Declare-styleable>

<Declare-styleable name = "ImageView">
<! -- Sets a drawable as the content of this ImageView. -->
<Attr name = "src" format = "reference | color"/>
<! -- Controls how the image shocould be resized or moved to match the size
Of this ImageView. -->
<Attr name = "scaleType">
<Enum name = "matrix" value = "0"/>
<Enum name = "fitXY" value = "1"/>
<Enum name = "fitStart" value = "2"/>
<Enum name = "fitCenter" value = "3"/>
<Enum name = "fitEnd" value = "4"/>
<Enum name = "center" value = "5"/>
<Enum name = "centerCrop" value = "6"/>
<Enum name = "centerInside" value = "7"/>
</Attr>
<! -- Set this to true if you want the ImageView to adjust its bounds
To preserve the aspect ratio of its drawable. -->
<Attr name = "adjustViewBounds" format = "boolean"/>
<! -- An optional argument to supply a maximum width for this view.
See {see android. widget. ImageView # setMaxWidth} for details. -->
<Attr name = "maxWidth" format = "dimension"/>
<! -- An optional argument to supply a maximum height for this view.
See {see android. widget. ImageView # setMaxHeight} for details. -->
<Attr name = "maxHeight" format = "dimension"/>
<! -- Set a tinting color for the image -->
<Attr name = "tint" format = "color"/>
<! -- If true, the image view will be baseline aligned with based on its
Bottom edge -->
<Attr name = "baselineAlignBottom" format = "boolean"/>
<! -- If true, the image will be cropped to fit within its padding -->
<Attr name = "cropToPadding" format = "boolean"/>
</Declare-styleable>
The above is extracted from the attrs. xml file. You can see some special attributes of ImageView (because ImageView inherits from View, the View attributes naturally inherit ).
Similarly, the Android system defines many attributes for Theme (you can see attrs. xml file). The names of each topic attribute correspond to themes in the Directory D: \ android-sdk \ platforms \ android-16 \ data \ res \ values. xml file. When topic attributes are used, you do not need to specify android: attr? Add the attribute name.

 

 


 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.