【发布时间】:2013-08-15 09:41:50
【问题描述】:
我在我的项目中使用了操作栏和导航抽屉。使用 appcompat v7 和 v4。
我已经添加了 appcompat v7 WITH 资源。
以下是我直接从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"/>
【问题讨论】:
-
你的
minSdkVersion是什么? -
@vikram - 抱歉 minSDK 版本是 10
-
@vikram,谢谢,也许我误解了,但我认为 appcompat 包 v7 及其资源应该可以解决这个问题?
-
我删除了我的评论,因为我忽略了
I have added the appcompat v7 WITH resources。这里的问题是属性activatedBackgroundIndicator。textAppearanceListItemSmall和listPreferredItemHeightSmall都在appcompat v7中定义,但activatedBackgroundIndicator不是。您可以通过查看sdk\extras\android\support\v7\appcompat\res\values\attrs.xml来验证这一点。activatedBackgroundIndicator在 API 11 中添加。这就是代码在 minsdk=10 时失败的原因。就像你说的:Above API 10 the code works fine. -
顺便说一下,这是
activatedBackgroundIndicator使用的drawable:Link。您可以尝试直接使用它(将其放在 res/drawable 中)。我不确定这是否可行。
标签: java android android-actionbar android-support-library navigation-drawer