android xml 资源
文件结构
/res/anim/ R.anim
tween_animations
/res/animator R.animator
property_animations
/res/color/
/res/drawable/ R.drawable
bitmaps
xml_drawable
frame_animations
/res/layout/ R.layout
/res/menu/ R.menu
/res/values/
attrs.xml
styles.xml R.string
themes.xml
strings.xml
colors.xml
dimen.xml
arrays.xml
bools.xml
integers.xml
/res/xml/
/assets/
android.content.res.Resources
int getColor(int id) //对应res/values/colors.xml
Drawable getDrawable(int id) //对应res/drawable/
XmlResourceParser getLayout(int id) //对应res/layout/
String getString(int id) 和CharSequence getText(int id) //对应res/values/strings.xml
InputStream openRawResource(int id) //对应res/raw/
void parseBundleExtra (String tagName, AttributeSet attrs, Bundle outBundle) //对应res/xml/
String[] getStringArray(int id) //对应res/values/arrays.xml
float getDimension(int id) //对应res/values/dimens.xml
解析资源 android.util.AttributeSet
@、@android:type、@*、?、@+
- @ 引用资源
引用自定义资源。格式:@[package:]type/name R.string.hello
引用系统资源。格式:@android:type/name android.R.drawable.dialog_frame
系统资源platforms\android-8\data\res\values\public.xml - @* 引用系统的非public资源
格式:@*android:type/name
- ? 引用当前主题属性
格式: ?android:[attr/]android:attrNameInTheme
例:android:textColor="?android:textDisabledColor" - @+ 创建或引用资源
格式:@+type/name
android:id="@+id/selectdlg" @+id/资源ID名 新建一个资源ID
android:id="@id/button3" @id/资源ID名 应用现有已定义的资源ID,包括系统ID
android:id="@android:id/text1" @android:id/资源ID名 引用系统ID,其等效于@id/资源ID名