导航抽屉Android API特定的布局属性

Kai*_*dul 9 api layout android

您好我已经创建了一个带有ListView导航的导航抽屉使用ActionBar Sherlockandroid support Library v4旧版本兼容性(我的应用程序的minSdkversion ="8"),其中我在ListView中使用了textview的一些属性:

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/title"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceListItemSmall"
    android:gravity="center_vertical"
    android:paddingLeft="16dp"
    android:paddingRight="5dp"
    android:textColor="#fff"
    android:background="?android:attr/activatedBackgroundIndicator"
    android:minHeight="?android:attr/listPreferredItemHeightSmall"/>
Run Code Online (Sandbox Code Playgroud)

这被示出误差?android:attr/activatedBackgroundIndicator是从API 11和?android:attr/textAppearanceListItemSmall&?android:attr/listPreferredItemHeightSmall是从API 14.

我设法?android:attr/activatedBackgroundIndicator通过用actionBar Sherlock替换它来支持?attr/activatedBackgroundIndicator.但我没有发现其他两个属性的任何等价.有?attr/textAppearanceListItemSmall在动作条福尔摩斯,但它不能正常工作.

那么这些属性的等价性为2.1以上的所有API提供支持?

yaj*_*esh 31

要支持较低版本,请不要删除以下三个参数,

  android:textAppearance="?android:attr/textAppearanceListItemSmall" 
  android:background="?android:attr/activatedBackgroundIndicator"
  android:minHeight="?android:attr/listPreferredItemHeightSmall"
Run Code Online (Sandbox Code Playgroud)

实际上,您可以使用等效的值/资源替换它们.

可以从https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/themes.xml获取等效值

现在,

  • 您还可以在值中创建API特定样式,值为v11 e tc (2认同)

Soc*_*ror 2

我不确定你是否真的需要使用android尺寸(比如listPreferredItemHeightSmall等)。在某些android版本中,该尺寸可以是12,而在其他版本中可以是14。我建议你创建自己的尺寸,它将在你的整个应用程序中使用,并且当需要更改时,您可以轻松编辑它们。

  • 还有一个问题。这个自定义尺寸看起来很完美。但这些尺寸与 Android 标准尺寸不同吗?我的意思是,这个尺寸的 android API 的值是多少? (2认同)