我在我的项目中使用了操作栏和抽屉导航。使用 appcompat v7 和 v4。
我已经添加了 appcompat v7 WITH 资源。
以下是我的抽屉导航列表的 TextView ,直接取自 Creating a Navigation Drawer 中的 android 示例应用程序。
底部三行都导致我的应用程序失败,它构建正常,但我强制关闭,我不确定如何解决问题。考虑到我添加了 appcompat 及其资源,我不明白为什么找不到属性。或者它们对 appcompat 或其他东西无效?
MinSDK 版本为 10,此时代码失败。 API 10 以上代码运行良好。
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:textColor="#fff"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:background="?android:attr/activatedBackgroundIndicator"
android:minHeight="?android:attr/listPreferredItemHeightSmall"/>
最佳答案
您可以使用兼容性库中定义的值:它指定除背景之外的所有值,我选择了 listChoiceBackgroundIndicator,尽管您也可以使用其他值。
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:textColor="#fff"
android:background="?attr/listChoiceBackgroundIndicator"
android:minHeight="?attr/listPreferredItemHeightSmall"/>
关于java - 使用 Appcompat v7 的抽屉导航 - Android :attr Tag 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18250096/