Mohamed El Kayal
Mohamed El Kayal

Reputation: 319

How to add Scroll View in my wearable app's xml file?

This is part of my xml code, my question is what changes should I make to add the scroll View. I want to be able to scroll down the activity. So do I change the layout from Circular Progress Layout to Box Inset Layout or is this irrelevant?

<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"/>

Upvotes: 0

Views: 1551

Answers (1)

lpizzinidev
lpizzinidev

Reputation: 13274

You should put all the content that you want to scroll inside a ScrollView with a single LinearLayout as first child like this

<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>

Upvotes: 1

Related Questions