0

这是我的 xml 代码的一部分,我的问题是我应该进行哪些更改来添加滚动视图。我希望能够向下滚动活动。那么我是否应该将布局从 Circular Progress Layout 更改为 Box Inset Layout 或者这无关紧要?

<androidx.wear.widget.CircularProgressLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/black"
    android:padding="@dimen/box_inset_layout_padding"
    tools:context=".MainActivity6"
    tools:deviceIds="wear">

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="@dimen/inner_frame_layout_padding"
    app:boxedEdges="all"
    tools:ignore="MissingPrefix">

    <TextView
        android:id="@+id/txt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:textColor="@color/orange"
        android:translationY="-70dp"
        android:text="Tool Number"/>
4

1 回答 1

0

您应该将所有要滚动的内容放在一个 ScrollView 中,其中一个 LinearLayout 作为第一个子项,如下所示

<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <androidx.wear.widget.CircularProgressLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/black"
            android:padding="@dimen/box_inset_layout_padding"
            tools:context=".MainActivity6"
            tools:deviceIds="wear">

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="@dimen/inner_frame_layout_padding"
            app:boxedEdges="all"
            tools:ignore="MissingPrefix">

            <TextView
                android:id="@+id/txt"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:textColor="@color/orange"
                android:translationY="-70dp"
                android:text="Tool Number"/>

        ...

    </LinearLayout

</ScrollView>
于 2020-11-16T13:19:54.240 回答