我正在尝试使我的 ICS(API 级别 15)应用程序与 Gingerbread(API 级别 10)兼容,并且我得到了 InflateException Error inflating class <Unknown>
对于任何具有 ?android:attr/
的布局 XML属性。如果我注释掉这些属性,我就可以编译并运行该应用程序,当然,它看起来很棒。
我不想复制 android.R.attr
中的所有项目我正在使用,但目前我不知道另一种方法。
我正在使用 ActionBarSherlock 让 ActionBar 正常工作,而且我似乎没有使用任何其他需要支持库的东西(尽管我在尝试解决这个问题的过程中已经包含了它),它只是我坚持使用这些基于主题的资源。
我使用的一些主题资源是:
?android:attr/textColorSecondaryInverse
?android:attr/textAppearanceLarge
?android:attr/dividerVertical
?android:attr/selectableItemBackground
?android:attr/textAppearanceMedium
?android:attr/dividerVertical
?android:attr/dividerHorizontal
最佳答案
使用 API 11 中的样式特别是 android:attr/textAppearanceMedium ?android:attr/dividerVertical ?android:attr/dividerHorizontal
最简单的方法是在你需要的地方使用下面的代码
<!-- For Horizontal Line-->
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:layout_marginLeft="4dip"
android:layout_marginRight="4dip"
android:background="#aaa"
android:layout_alignParentTop="true"/>
<!-- For Vertical Line-->
<View
android:id="@+id/VerticalLine"
android:layout_width="1dip"
android:layout_height="wrap_content"
android:layout_marginBottom="4dip"
android:layout_marginTop="4dip"
android:background="#aaa"/>
关于java - 使用 ?android :attr/in backwards compatible apps,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11383033/