如何修复嵌套在 ScrollView 中的 BoxInsetLayout 内的包装元素
How to fix wrapping elements inside BoxInsetLayout nested in ScrollView
我想实现 scrollable BoxInsetlayout,子项从顶部和侧面装箱。将组件包裹在 ScrollView 嵌套的 BoxInsetLayout 的子项中似乎有问题。是因为不能为wrap-content设置BoxInsentLayout吗?
这是我的例子:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:deviceIds="wear">
<android.support.wear.widget.BoxInsetLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
app:boxedEdges="left|top|right" >
<TextView
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/hello_world"
android:textAlignment="center"
android:textColor="@color/black"
android:visibility="visible" />
</LinearLayout>
</android.support.wear.widget.BoxInsetLayout>
</ScrollView>
结果:
期望:
解决方案是添加:android:fillViewport="true"
。
我想实现 scrollable BoxInsetlayout,子项从顶部和侧面装箱。将组件包裹在 ScrollView 嵌套的 BoxInsetLayout 的子项中似乎有问题。是因为不能为wrap-content设置BoxInsentLayout吗?
这是我的例子:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:deviceIds="wear">
<android.support.wear.widget.BoxInsetLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
app:boxedEdges="left|top|right" >
<TextView
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/hello_world"
android:textAlignment="center"
android:textColor="@color/black"
android:visibility="visible" />
</LinearLayout>
</android.support.wear.widget.BoxInsetLayout>
</ScrollView>
结果:
期望:
解决方案是添加:android:fillViewport="true"
。