关于android.R

源码中经常会出现使用android.R.xx的地方或者是在xml文件中出现@android:xxx/xxx。刚开始经常不理解这个是在系统哪里定义过的

后来看到google文档中的定义如下:

Contains resource classes used by applications included in the platform and defines application permissions for system features.

You can use some resources directly from these R classes in your own applications, but you should generally use only resources that you've provided directly in your application, in order to provide a cohesive application package that has no external dependencies.In particular, you should not use drawable resources from the android package, because they may change between platform versions, causing unforeseen conflicts with your design. Typically,styles are the only resources you should use directly from these resources.

包含了一些系统定义的资源类和定义的应用程序权限。

你可以在你的应用中通过使用这些R类来使用资源,但是通常应该在应用中使用自定义的唯一的资源,目的是提供一个没有外部依赖的包。特别是,你不应该使用android系统里的图片资源。因为应用在不同版本的平台切换的时候会对你的界面设计及造成不可遇见的冲突。通常,样式风格应该使用自定义的资源。

总结一句话,其实就是说在自己的应用中应该使用自己定义的资源。

android内置的资源还是挺多的,有系统定义的动画、风格、图片等等,具体的可以在谷歌文档上看到。其实这些系统定义的资源都是在framework/base/core/res/res里面的xml文件定义好的。使用android.R.xx或者@android:xxx/xxx其实就是调用这个地方的内容


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值