gpt4 book ai didi

android - 无法将卡片与 Android Wear 底部对齐

转载 作者:太空宇宙 更新时间:2023-11-03 13:16:40 25 4
gpt4 key购买 nike

我正在遵循 Android 文档中的教程 here但他们没有按照我的期望去做。

我创建了一个 CardFrame 来在 watch 上显示一张卡片,并使用属性 app:layout_box="bottom" 让它出现在 watch 的底部,但正如您所看到的屏幕截图并非如此。这是我的 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>

这是卡片的截图:

enter image description here

谁能阐明为什么该属性没有按预期工作?

最佳答案

CardFrame 标签中添加属性 android:layout_gravity="bottom" ,如下所示:

<android.support.wearable.view.CardFrame
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="bottom">

这解决了我的问题,卡片出现在底部。

解释:我认为 cardframe 教程中属性“layout_box”的含义不是很清楚。来自 BoxInsetLayout docs ,似乎 layout_box="bottom"的意思是“确保 CardScrollView 的底部包含(或装箱)在 centre box 内”。这样可以防止卡的底部被裁掉。这并不意味着“在底部对齐”。 layout_gravity 属性将卡片放在底部。 layout_box 属性确保卡片内容的底部不会被裁剪掉。

关于android - 无法将卡片与 Android Wear 底部对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35005844/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com