如何修复ScrollView中嵌套的BoxInsetLayout中的包装元素

时间:2019-03-28 11:48:32

标签: android android-layout user-interface scroll wear-os

我想实现可滚动 BoxInsetlayout,并在顶部和侧面将子级框起来。在ScrollView嵌套的BoxInsetLayout的子级内部包装组件似乎有问题。这是因为不能为包装内容设置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>

结果:
result

期望:
![expectiation](https://ibb.co/vjPPmZR)

1 个答案:

答案 0 :(得分:0)

为此的解决方案是添加:android:fillViewport="true"