0

我正在研究Android中的表單,該表單適用於爲我的應用創建功能。但目前我正在使用帶有嵌套滾動視圖的CoordinatorLayout。但它在我的卷軸底部留出空白。如何刪除這個?嵌套的滾動視圖在CoordinatorLayout中佔用額外的空間

這裏是我的xml:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@color/ash" 
android:orientation="vertical"> 

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/ash" 
    android:fitsSystemWindows="true"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/app_bar_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fitsSystemWindows="true" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/ctl" 
      android:layout_width="match_parent" 
      android:layout_height="350dp" 
      android:background="@color/ash" 
      android:fitsSystemWindows="true" 
      app:contentScrim="?attr/colorPrimary" 
      app:expandedTitleTextAppearance="@android:color/transparent" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:background="@drawable/layout_layer" 
       android:gravity="center_horizontal" 
       android:orientation="vertical"> 

       <ImageView 
        android:id="@+id/img_chatroom" 
        android:layout_width="match_parent" 
        android:layout_height="150dp" 
        android:contentDescription="@string/app_name" 
        android:scaleType="centerCrop" 
        android:src="@drawable/profile_img_bg" 
        app:layout_collapseMode="parallax" /> 

       <TextView 
        android:id="@+id/tv_chatroomname" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_below="@+id/img_chatroom" 
        android:gravity="center_horizontal" 
        android:padding="5dp" 
        android:text="Chatroom Name" 
        android:textColor="@color/black" 
        android:textSize="@dimen/large_text" /> 

       <TextView 
        android:id="@+id/tv_chatroomdescription" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_below="@+id/tv_chatroomname" 
        android:layout_margin="10dp" 
        android:padding="5dp" 
        android:text="Chatroom DescriptionChatroom DescriptionChatroomChatroom DescriptionChatroom DescriptionChatroomChatroom DescriptionChatroom DescriptionChatroomChatroom DescriptionChatroom DescriptionChatroom" 
        android:textColor="@color/black" 
        android:textSize="@dimen/small_text" /> 
      </RelativeLayout> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:title="Settings" 
       app:layout_collapseMode="pin" /> 
     </android.support.design.widget.CollapsingToolbarLayout> 
    </android.support.design.widget.AppBarLayout> 


    <android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@drawable/layout_layer" 
      android:orientation="vertical"> 

      <RelativeLayout 
       android:id="@+id/rl_create_menu" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/rl_picture" 
       android:layout_margin="10dp"> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_margin="10dp" 
        android:orientation="vertical"> 

        <LinearLayout 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_margin="10dp" 
         android:orientation="horizontal"> 

         <TextView 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center" 
          android:layout_weight="1" 
          android:text="Chatroom Type" 
          android:textColor="@color/black" /> 

         <RadioGroup 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:orientation="horizontal"> 

          <RadioButton 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:text="Public" 
           android:theme="@style/MyRadioButton" /> 

          <RadioButton 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:text="Private" 
           android:theme="@style/MyRadioButton" /> 
         </RadioGroup> 

        </LinearLayout> 

        <LinearLayout 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:gravity="center_vertical" 
         android:padding="10dp"> 


         <LinearLayout 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:orientation="vertical"> 

          <RelativeLayout 
           android:id="@+id/rl_country_res" 
           android:layout_width="wrap_content" 
           android:layout_height="match_parent"> 

           <TextView 
            android:layout_width="match_parent" 
            android:layout_height="wrap_content" 
            android:layout_gravity="center_vertical" 
            android:text="Country Wise Restriction" 
            android:textColor="@color/black" 
            android:textSize="@dimen/small_medium_text" /> 
          </RelativeLayout> 

          <View 
           android:layout_width="match_parent" 
           android:layout_height="0.5dp" 
           android:layout_gravity="bottom" 
           android:layout_marginTop="10dp" 
           android:background="@color/deep_ash" /> 

          <RelativeLayout 
           android:id="@+id/rl_chatroom_capacity" 
           android:layout_width="match_parent" 
           android:layout_height="wrap_content" 
           android:layout_marginTop="15dp"> 

           <TextView 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="Chatroom Capacity" 
            android:textColor="@color/black" 
            android:textSize="@dimen/small_medium" /> 
          </RelativeLayout> 

          <View 
           android:layout_width="match_parent" 
           android:layout_height="0.5dp" 
           android:background="@color/ash" /> 

          <RelativeLayout 
           android:id="@+id/rl_country" 
           android:layout_width="match_parent" 
           android:layout_height="wrap_content" 
           android:layout_marginTop="15dp"> 

           <TextView 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="Country" 
            android:textColor="@color/black" 
            android:textSize="@dimen/small_medium" /> 
          </RelativeLayout> 

          <View 
           android:layout_width="match_parent" 
           android:layout_height="0.5dp" 
           android:layout_gravity="bottom" 
           android:background="@color/ash" /> 

          <RelativeLayout 
           android:layout_width="match_parent" 
           android:layout_height="wrap_content" 
           android:layout_marginTop="5dp" 
           android:padding="5dp"> 

           <TextView 
            android:id="@+id/tv_protect_chatroom" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="Protect Chatroom" 
            android:textColor="@color/black" 
            android:textSize="@dimen/small_medium" /> 

           <ToggleButton 
            android:layout_width="40dp" 
            android:layout_height="18dp" 
            android:layout_alignParentRight="true" 
            android:background="@drawable/toggle_silector" 
            android:checked="false" 
            android:text="" 
            android:textOff="" 
            android:textOn="" /> 

           <TextView 
            android:layout_width="match_parent" 
            android:layout_height="wrap_content" 
            android:layout_below="@+id/tv_protect_chatroom" 
            android:layout_marginTop="10dp" 
            android:text="Without code no one can join with you" /> 
          </RelativeLayout> 

          <RelativeLayout 
           android:layout_width="match_parent" 
           android:layout_height="wrap_content" 
           android:layout_marginTop="5dp" 
           android:padding="5dp"> 

           <TextView 
            android:id="@+id/tv_auto_flood_control" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="Auto Flood Control" 
            android:textColor="@color/black" 
            android:textSize="@dimen/small_medium" /> 

           <ToggleButton 
            android:layout_width="40dp" 
            android:layout_height="18dp" 
            android:layout_alignParentRight="true" 
            android:background="@drawable/toggle_silector" 
            android:checked="false" 
            android:text="" 
            android:textOff="" 
            android:textOn="" /> 

           <TextView 
            android:layout_width="match_parent" 
            android:layout_height="wrap_content" 
            android:layout_below="@+id/tv_auto_flood_control" 
            android:layout_marginTop="10dp" 
            android:text="If you enable flood control , User will be kicked automatically from chatroom" /> 
          </RelativeLayout> 

          <RelativeLayout 
           android:id="@+id/rl_idle_time" 
           android:layout_width="match_parent" 
           android:layout_height="wrap_content" 
           android:layout_marginTop="15dp"> 

           <TextView 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="Maximum Idle Time" 
            android:textColor="@color/black" 
            android:textSize="@dimen/small_medium" /> 
          </RelativeLayout> 

          <Button 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:layout_gravity="center" 
           android:layout_marginTop="35dp" 
           android:background="@drawable/shape_for_submit_button" 
           android:gravity="center" 
           android:padding="4dp" 
           android:text="Create Chatroom" 
           android:textColor="@color/black" 
           android:textSize="@dimen/small_medium" /> 
         </LinearLayout> 
        </LinearLayout> 
       </LinearLayout> 
      </RelativeLayout> 
     </LinearLayout> 
    </android.support.v4.widget.NestedScrollView> 
</android.support.design.widget.CoordinatorLayout> 

我試過在堆棧溢出發現幾件事情,但不是我working.How可以解決這個問題?

+0

你會在這裏額外的空間發佈你的輸出? – sushildlh

+0

抱歉,兄弟,這是一個上傳圖片的問題,但我會再試一次,讓你知道。但問題是,當我向下滾動時,總是會在底部創建一個額外的空白空間。 –

回答

0

更改高度match_parent

<android.support.v4.widget.NestedScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#Ff0000" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

我添加了background,你可以看到它的顏色。

+0

不工作的兄弟。 –

+0

嘗試看看背景的顏色。 – KeLiuyue

+0

直到現在還沒有工作... –