Java – how do I add a scrolling view to the entire activity?
•
Java
I tried to add a scrolling view around everything on the active layout, but it gave me an error that it can only be placed on one thing
My activity has a title textview, then an image, and then a description text view. You can't read the whole description because it's long and below the edge of my screen How to make whoel things scrollable?
My XML looks like this:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/beerTitle" android:layout_width="fill_parent" android:layout_height="wrap_content" android:ems="10" android:textSize="40sp" android:textStyle = "bold" > </TextView> <ImageView android:id="@+id/image" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_margin="10dip"/> <Button android:id="@+id/buttonBrewery" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="" /> <Button android:id="@+id/buttonStyle" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="" /> <TextView android:id="@+id/beerDEscriptionTitle" android:textStyle = "bold" android:layout_width="fill_parent" android:layout_height="wrap_content" android:ems="10" android:textSize="20sp" android:text="Description" ></TextView> <TextView android:id="@+id/beerDescription" android:layout_width="fill_parent" android:layout_height="wrap_content" android:ems="10" android:textSize="15sp" ></TextView> </LinearLayout>
Solution
Try this:
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <!-- TextView and other stuff --> </LinearLayout> </ScrollView>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码