无法将卡片与 Android 磨损的底部对齐
Unable to align Card to bottom of Android Wear
我正在按照 Android 文档 here 中的教程进行操作,但他们没有按照我的期望去做。
我创建了一个 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>
这是卡片的屏幕截图:
任何人都可以阐明为什么该属性没有按预期工作吗?
在CardFrame标签中添加属性android:layout_gravity="bottom",像这样:
<android.support.wearable.view.CardFrame
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="bottom">
这解决了我的问题,卡片出现在底部。
说明:
我认为属性 "layout_box" 的含义从 cardframe 教程中不是很清楚。来自 BoxInsetLayout docs, it appears that the layout_box="bottom" means "make sure that the bottom of the CardScrollView is contained (or boxed) inside the centre box”。这可以防止卡的底部被裁掉。它并不意味着 "align at the bottom"。layout_gravity 属性将卡放在底部。layout_box 属性确保卡片内容的底部不会被裁掉。
我正在按照 Android 文档 here 中的教程进行操作,但他们没有按照我的期望去做。
我创建了一个 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>
这是卡片的屏幕截图:
任何人都可以阐明为什么该属性没有按预期工作吗?
在CardFrame标签中添加属性android:layout_gravity="bottom",像这样:
<android.support.wearable.view.CardFrame
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="bottom">
这解决了我的问题,卡片出现在底部。
说明: 我认为属性 "layout_box" 的含义从 cardframe 教程中不是很清楚。来自 BoxInsetLayout docs, it appears that the layout_box="bottom" means "make sure that the bottom of the CardScrollView is contained (or boxed) inside the centre box”。这可以防止卡的底部被裁掉。它并不意味着 "align at the bottom"。layout_gravity 属性将卡放在底部。layout_box 属性确保卡片内容的底部不会被裁掉。