Android layout 如何为整个布局创建滚动视图?

Android layout 如何为整个布局创建滚动视图?,android-layout,android-studio,scrollview,Android Layout,Android Studio,Scrollview,我想将滚动视图添加到此布局,但不知道如何添加?当我将scrollview添加到整个布局中时,每个相对布局的大小都会增加,并且第二个相对布局很长。我希望两种布局都能完美地配合屏幕 activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:lay

我想将滚动视图添加到此布局,但不知道如何添加?当我将scrollview添加到整个布局中时,每个相对布局的大小都会增加,并且第二个相对布局很长。我希望两种布局都能完美地配合屏幕

activity_main.xml

<LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   tools:context="com.example.android.ridhwan.MainActivity"
   android:orientation="vertical">

  <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1">

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

       <ImageView
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:src="@drawable/main1"
           android:scaleType="centerCrop" />

       <ImageView
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:src="@drawable/main2"
           android:scaleType="centerCrop" />

       <ImageView
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:src="@drawable/masjid"
           android:scaleType="centerCrop" />

       <ImageView
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:src="@drawable/main3"
           android:scaleType="centerCrop" />

    </ViewFlipper>

    <Button
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="DUBAI"
        android:textSize="40sp"
        android:textColor="#ffffff"
        android:id="@+id/dubaibutton"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:clickable="true"
        android:background="#49000000"
        />
  </RelativeLayout>

  <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1">

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


      <ImageView
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:src="@drawable/india1"
          android:scaleType="centerCrop" />

      <ImageView
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:src="@drawable/india2"
          android:scaleType="centerCrop" />

      <ImageView
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:src="@drawable/india3"
          android:scaleType="centerCrop" />

      <ImageView
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:src="@drawable/india"
          android:scaleType="centerCrop" />

   </ViewFlipper>


       <Button
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="INDIA"
            android:textSize="40sp"
            android:textColor="#ffffff"
            android:id="@+id/indiabutton"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true"
            android:clickable="true"
            android:background="#49000000"
            />
   </RelativeLayout>

  </LinearLayout>