[英]Navigation Drawer Android API specific Layout Attribute
您好我已經使用ActionBar Sherlock
和android 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獲取等效值
現在,
a) android:textAppearance="@android:style/TextAppearance.Medium"
b)
在上面的項目中瀏覽hdpi,mdpi等資源並獲取名為list_activated_holo.9.png的文件
最后
android:background="@drawable/list_item_activated_background"
c)從獲得的等效值中,我們知道listPreferredItemHeightSmall是48dip
android:minHeight="48dip"
我不確定你是否真的需要使用android尺寸(如listPreferredItemHeightSmall
等)。在某些Android版本中,該尺寸可以是12而在其他14中。我建議您創建自己的尺寸,這將在您的整個應用中使用,並且您可以在需要更改時輕松編輯它們。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.