簡體   English   中英

導航抽屜Android API特定的布局屬性

[英]Navigation Drawer Android API specific Layout Attribute

您好我已經使用ActionBar Sherlockandroid support Library v4創建了一個帶有ListView導航的導航抽屜,用於舊版本兼容性(我的應用程序的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"/>

這顯示錯誤為?android:attr/activatedBackgroundIndicator來自API 11和?android:attr/textAppearanceListItemSmall?android:attr/listPreferredItemHeightSmall來自API 14。

我設法支持?android:attr/activatedBackgroundIndicator ,用actionBar Sherlock的?attr/activatedBackgroundIndicator替換它。 但我沒有發現其他兩個屬性的任何等價。 actionBar Sherlock中有?attr/textAppearanceListItemSmall但它沒有正常工作。

那么這些屬性的等價性為2.1以上的所有API提供支持?

要支持較低版本,請不要刪除以下三個參數,

  android:textAppearance="?android:attr/textAppearanceListItemSmall" 
  android:background="?android:attr/activatedBackgroundIndicator"
  android:minHeight="?android:attr/listPreferredItemHeightSmall"

實際上,您可以使用等效的值/資源替換它們。

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

現在,

我不確定你是否真的需要使用android尺寸(如listPreferredItemHeightSmall等)。在某些Android版本中,該尺寸可以是12而在其他14中。我建議您創建自己的尺寸,這將在您的整個應用中使用,並且您可以在需要更改時輕松編輯它們。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM