[英]Card Fragment in Android wear does not appear on bottom of screen
[英]Unable to align Card to bottom of Android Wear
我下面從Android文檔教程在這里 ,但他們沒有做什么,我希望他們。
我創建了一個CardFrame來在手表上顯示一張卡片並使用屬性app:layout_box="bottom"
讓它出現在手表的底部,但正如您所看到的截圖並非如此。 這是我的XML:
<android.support.wearable.view.BoxInsetLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent">
<android.support.wearable.view.CardScrollView
android:id="@+id/card_scroll_view"
android:layout_height="wrap_content"
android:layout_width="match_parent"
app:layout_box="bottom">
<android.support.wearable.view.CardFrame
android:layout_height="wrap_content"
android:layout_width="match_parent">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical"
android:paddingLeft="5dp">
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="Custom Title"
android:textColor="@color/black"
android:textSize="20sp"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="Custom Description"
android:textColor="@color/black"
android:textSize="14sp"/>
</LinearLayout>
</android.support.wearable.view.CardFrame>
</android.support.wearable.view.CardScrollView>
</android.support.wearable.view.BoxInsetLayout>
這是卡的屏幕截圖:
任何人都可以解釋為什么該屬性沒有按預期工作?
將屬性android:layout_gravity =“bottom”添加到CardFrame標記中,如下所示:
<android.support.wearable.view.CardFrame
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="bottom">
這解決了我的問題,卡片出現在底部。
說明:我認為屬性“layout_box”的含義在cardframe教程中並不十分清楚。 從BoxInsetLayout 文檔中 ,看來layout_box =“bottom”表示“確保CardScrollView的底部包含(或裝箱)在中心框內 ”。 這可以防止卡的底部被裁掉。 它並不意味着“在底部對齊”。 layout_gravity屬性將卡片放在底部。 layout_box屬性可確保不會裁掉卡片內容的底部。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.