为资源Resource创建别名 引用style资源
来源:互联网 发布:软件用户手册模板 编辑:程序博客网 时间:2024/05/22 08:26
Crete resources aliases
you can even use resources in XML to create aliases. For example, you can create adrawable resource that is an alias for another drawable resource:
<?xml version="1.0" encoding="utf-8"?><bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/other_drawable" />
This sounds redundant, but can be very useful when using alternative resource. Read more aboutCreating alias resources.
Referencing style attributes
A style attribute resource allows you to reference the valueof an attribute in the currently-applied theme. Referencing a style attribute allows you tocustomize the look of UI elements by styling them to match standard variations supplied by thecurrent theme, instead of supplying a hard-coded value. Referencing a style attributeessentially says, "use the style that is defined by this attribute, in the current theme."
To reference a style attribute, the name syntax is almost identical to the normal resourceformat, but instead of the at-symbol (@
), use a question-mark (?
), and theresource type portion is optional. For instance:
?[<package_name>:][<resource_type>/]<resource_name>
For example, here's how you can reference an attribute to set the text color to match the"primary" text color of the system theme:
<EditText id="text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="?android:textColorSecondary" android:text="@string/hello_world" />
Here, the android:textColor
attribute specifies the name of a style attributein the current theme. Android now uses the value applied to theandroid:textColorSecondary
style attribute as the value forandroid:textColor
in this widget. Because the systemresource tool knows that an attribute resource is expected in this context,you do not need to explicitly state the type (which would be?android:attr/textColorSecondary
)—you can exclude theattr
type.
- 为资源Resource创建别名 引用style资源
- Style Resource(样式资源)
- Android中引用style资源
- Android 资源目录(Style Resource)介绍
- Resource(资源)
- 资源resource
- 资源 Resource
- Android - 资源(resource)转换为String
- android-支持多种屏幕[创建别名资源] 十三
- 资源引用
- android中资源的创建与引用
- Andoid Style资源应用
- 样式<style>资源
- 资源注射(@Resource)
- 关于资源Resource
- Android - 资源(resource)
- Android - 使用资源(resource)
- spring resource资源
- android 删除SD卡或者手机的缓存图片和目录
- android系统广播使用经验
- python的format函数
- Linux wget命令设置代理
- Live555/ffmpeg(NEON支持)/boost交叉编译(整理版)
- 为资源Resource创建别名 引用style资源
- 根据图片名字在drawable中得到图片
- Java基本开发环境搭建
- SQL存储过程前面有语句set ANSI_NULLS ON set QUOTED_IDENTIFIER ON
- windows下如何正确使用Jconsole远程连接linux主机上的JVM
- 在调用Fragment.setListShown()报java.lang.IllegalStateException: Content view not yet created的错误
- 游标使用
- 100行代码实现最简单的基于FFMPEG+SDL的视频播放器
- 伯明汉教育-仅凭中、高考准考证,学费直减!!