如何为整个布局制作ScrollView?

时间:2016-07-10 04:10:42

标签: android-layout android-studio scrollview

我想将Scroll View添加到此布局,但不知道如何?当我将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>

0 个答案:

没有答案