How to make all contents of android scoll page up

On my Android app page, I use slider, text image and gridview to display images. Now the problem is that when I scroll up, only the gridview scrolling images and the rest of the things remain static. Please help me, how can I move the entire contents of the page when I scroll?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >`enter code here`

    <ViewFlipper
        android:id="@+id/viewFlipper1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
          <ImageView
            android:layout_width="fill_parent"
            android:layout_height="150dp"
            android:src="@drawable/one" />
         <ImageView
            android:layout_width="fill_parent"
            android:layout_height="150dp"
            android:src="@drawable/two" />

        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="150dp"
            android:src="@drawable/three" />

        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="150dp"
            android:src="@drawable/banner1" />

        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="150dp"
            android:src="@drawable/banner2" />

        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="150dp"
            android:src="@drawable/banner3" />

        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="150dp"
            android:src="@drawable/banner4" />
    </ViewFlipper>    

        <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Shop For"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:layout_marginLeft="100dp" />

      <GridView
          android:id="@+id/gridView1"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:columnWidth="150dp"
          android:gravity="center"
          android:horizontalSpacing="1dp"
          android:numColumns="2"
          android:padding="28dp"
          android:stretchMode="none"
          android:verticalSpacing="1dp"
          android:visibility="visible" >
    </GridView>


</LinearLayout>
+4
source share
2 answers

Put all the code in the scroll using the following code

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >

            <ViewFlipper
                android:id="@+id/viewFlipper1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >

                <ImageView
                    android:layout_width="fill_parent"
                    android:layout_height="150dp"
                    android:src="@drawable/one" />
                <ImageView
                    android:layout_width="fill_parent"
                    android:layout_height="150dp"
                    android:src="@drawable/two" />

                <ImageView
                    android:layout_width="fill_parent"
                    android:layout_height="150dp"
                    android:src="@drawable/three" />

                <ImageView
                    android:layout_width="fill_parent"
                    android:layout_height="150dp"
                    android:src="@drawable/banner1" />

                <ImageView
                    android:layout_width="fill_parent"
                    android:layout_height="150dp"
                    android:src="@drawable/banner2" />

                <ImageView
                    android:layout_width="fill_parent"
                    android:layout_height="150dp"
                    android:src="@drawable/banner3" />

                <ImageView
                    android:layout_width="fill_parent"
                    android:layout_height="150dp"
                    android:src="@drawable/banner4" />

            </ViewFlipper>

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Shop For"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:layout_marginLeft="100dp" />

            <GridView
                android:id="@+id/gridView1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:columnWidth="150dp"
                android:gravity="center"
                android:horizontalSpacing="1dp"
                android:numColumns="2"
                android:padding="28dp"
                android:stretchMode="none"
                android:verticalSpacing="1dp"
                android:visibility="visible" />

        </LinearLayout>

    </ScrollView>

If you have any problem, feel free to comment.

+2
source

Modify your layout xml file as below, it will probably solve your problem.

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

        <ViewFlipper
            android:id="@+id/viewFlipper1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
            <ImageView
                android:layout_width="fill_parent"
                android:layout_height="150dp"
                android:src="@drawable/one" />
            <ImageView
                android:layout_width="fill_parent"
                android:layout_height="150dp"
                android:src="@drawable/two" />

            <ImageView
                android:layout_width="fill_parent"
                android:layout_height="150dp"
                android:src="@drawable/three" />

            <ImageView
                android:layout_width="fill_parent"
                android:layout_height="150dp"
                android:src="@drawable/banner1" />

            <ImageView
                android:layout_width="fill_parent"
                android:layout_height="150dp"
                android:src="@drawable/banner2" />

            <ImageView
                android:layout_width="fill_parent"
                android:layout_height="150dp"
                android:src="@drawable/banner3" />

            <ImageView
                android:layout_width="fill_parent"
                android:layout_height="150dp"
                android:src="@drawable/banner4" />
        </ViewFlipper>

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Shop For"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_marginLeft="100dp" />

        <GridView
            android:id="@+id/gridView1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:columnWidth="150dp"
            android:gravity="center"
            android:horizontalSpacing="1dp"
            android:numColumns="2"
            android:padding="28dp"
            android:stretchMode="none"
            android:verticalSpacing="1dp"
            android:visibility="visible" >
        </GridView>
    </LinearLayout>
</ScrollView>

, ScrollView. ScrollView . , LinearLayout LinearLayout ScrollView.

Gridview ScrollView, Gridview , .

+1

Source: https://habr.com/ru/post/1611710/


All Articles