I am a newbie and trying to understand the following XML code:
Looking at the documentation at developer.android.com, it says "starStyle" is a constant in R.attr and
public static final int starStyle Since: API Level 1
Default Star style.
It seems to say that there are 2 syntax I can declare. 1) "@[+][package:]type:name" 2) "?[package:][type:]name".
If there are 2 syntax, what is the correct one for "@[+][package:]type:name" ?
I tried ""@android:attr/starStyle" but I didn't get a "star" checkbox even though the application compiled ok.
The @-syntax is used for resources that are defined in your project or the Android framework. The ?-syntax is used for resources in the current theme.
For starStyle, which should be defined in the theme, you want:
"?android:attr/starStyle"
See here for some elaboration on theme resources.
Android provides a shortcut to enable you to
use styles from the currently applied theme.
To do this, use ?android:
rather than @ as a prefix to the resource you want to use.
example:
<EditText
android:id="@+id/myEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@android:string/url"
android:textColor="?android:textColor"
/>
This technique enables you to create styles that change if the current theme changes, without you modifying each individual style resource.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With