android - Android R 类中的 attr 是什么?

标签 android android-layout

我在自动生成的 R.java 类中看到了一个名为 attr 的空类;它的意义是什么?我知道样式可以在 style.xml 中用 style 标签定义,所以我不知道 attr 是什么?

最佳答案

R.attr 用于“主题属性”(不是样式)。

它们在值 xml 文件中定义,如下所示:

<attr name="textAppearanceLarge" format="reference" />

它们在 View 构造函数中用于 defStyle 参数,如下所示:

public TextView (Context context, AttributeSet attrs, int defStyle)

我想应用程序添加自己的 attr 值的情况非常罕见。通常,如果有的话,将使用 android.R.attr 中的那些。

关于android - Android R 类中的 attr 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5633880/

相关文章:

android - 如何在屏幕上显示确切数量的 ListView 项目?

android - 如何在拍照过程中锁定相机屏幕方向?

android - 如何设置 editText 首选项的范围?

java - Android (Java) HttpURLConnection 静默重试 'read' 超时

GET 方法的 java.lang.IllegalArgumentException : baseUrl must end in/while using retrofit 2. 1.0

android - 如何删除 ImageView 以使其不再存在?

android - Apktool-检索项目 : No resource found that matches the given name 的父级时出错

Android - EditText 以编程方式不显示键盘

android - 如何最大程度地对齐 View ?

java - ANDROID : give id into widget such as Textview, Edittext,动态行/ View 中的微调器并将其存储到 sqlite 中