2016-06-21 3 views
2

CoordinatorLayoutの中にNestedScrollviewを実装する際の問題に直面しています。以下のレイアウトコードを参照してください。したがって、基本的CoordinatorLayoutでネストされたスクロールビューが空きスペースを取らない

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

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

    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapsing_toolbar_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

     <LinearLayout 
      android:layout_marginTop="?android:attr/actionBarSize" 
      app:layout_collapseMode="parallax" 
      android:layout_width="match_parent" 
      android:weightSum="2" 
      android:orientation="horizontal" 
      android:gravity="bottom" 
      android:fitsSystemWindows="true" 
      android:background="@color/aop_gray" 
      android:layout_height="87dp"> 

      <LinearLayout 
       android:background="#E5E5E5" 
       android:layout_width="0dp" 
       android:layout_weight="1" 
       android:layout_height="match_parent"> 

      </LinearLayout> 

      <LinearLayout 
       android:layout_width="0dp" 
       android:layout_weight="1" 
       android:layout_height="match_parent"> 
      </LinearLayout> 

     </LinearLayout> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar_anders" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="@color/Custom_red" 
      style="@style/CustomTheme.CustomActionBar" 
      android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
      /> 
     </android.support.design.widget.CollapsingToolbarLayout> 
    </android.support.design.widget.AppBarLayout> 

    <android.support.v4.widget.NestedScrollView 
     android:id="@+id/scroll" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:clipToPadding="false" 
     android:paddingTop="@dimen/activity_horizontal_margin" 
     android:paddingBottom="@dimen/activity_horizontal_margin" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <LinearLayout 
      android:id="@+id/test1" 
      android:layout_gravity="fill_vertical" 
      android:layout_width="match_parent" 
      android:orientation="vertical" 
      android:layout_height="match_parent"> 

      <com.Custom.saving.widgets.CustomTextView 
       android:id="@+id/aop_data_overview_form_header" 
       android:gravity="center" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:paddingRight="@dimen/activity_horizontal_margin" 
       android:paddingLeft="@dimen/activity_horizontal_margin" 
       style="@style/AopHeader" 
       android:layout_marginBottom="@dimen/default_margin" 
       android:text="@string/is_your_data_correct_header" /> 

      <com.Custom.saving.widgets.CustomTextView 
       android:layout_marginTop="@dimen/default_margin" 
       android:paddingRight="@dimen/activity_horizontal_margin" 
       android:paddingLeft="@dimen/activity_horizontal_margin" 
       android:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
       style="@style/TextViewGray" 
       android:textColor="#787878" 
       android:text="@string/aop_form_header"/> 

      <com.Custom.saving.widgets.CustomTextView 
       android:layout_marginTop="@dimen/default_margin" 
       android:paddingRight="@dimen/activity_horizontal_margin" 
       android:paddingLeft="@dimen/activity_horizontal_margin" 
       android:layout_width="wrap_content" 
       style="@style/AopBlueParagraph" 
       android:text="@string/aop_identity_data" 
       android:layout_height="wrap_content"/> 

      <android.support.v7.widget.CardView 
       android:id="@+id/card_view2" 
       android:layout_width="match_parent" 
       android:layout_marginTop="@dimen/activity_vertical_margin" 
       card_view:cardElevation="5dp" 
       android:background="@color/white" 
       android:gravity="center_horizontal" 
       card_view:cardCornerRadius="4dp" 
       android:layout_height="wrap_content"> 

       <LinearLayout 
        style="@style/ActivityContent" 
        android:paddingBottom="@dimen/activity_vertical_margin" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:gravity="center_horizontal" 
        android:orientation="vertical"> 

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

         <RadioButton 
          android:layout_width="wrap_content" 
          android:layout_marginRight="@dimen/default_margin" 
          android:layout_height="wrap_content" 
          android:text="Man"/> 

         <RadioButton 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text="Vrouw"/> 

        </RadioGroup> 


        <android.support.design.widget.TextInputLayout 
         android:layout_width="match_parent" 
         android:layout_marginTop="@dimen/small_margin" 
         app:hintTextAppearance="@style/TextInputLayoutStyle" 
         android:layout_height="wrap_content"> 

         <com.Custom.saving.widgets.CustomEditText 
          style="@style/Input" 
          android:layout_marginTop="@dimen/small_margin" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:hint="Voornaam"/> 

        </android.support.design.widget.TextInputLayout> 

        <android.support.design.widget.TextInputLayout 
         android:layout_width="match_parent" 
         app:hintTextAppearance="@style/TextInputLayoutStyle" 
         android:layout_marginTop="@dimen/small_margin" 
         android:layout_height="wrap_content"> 

         <com.Custom.saving.widgets.CustomEditText 
          style="@style/Input" 
          android:layout_marginTop="@dimen/small_margin" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:hint="Achternaam"/> 

        </android.support.design.widget.TextInputLayout> 

        <android.support.design.widget.TextInputLayout 
         android:layout_width="match_parent" 
         app:hintTextAppearance="@style/TextInputLayoutStyle" 
         android:layout_marginTop="@dimen/small_margin" 
         android:layout_height="wrap_content"> 

         <com.Custom.saving.widgets.CustomEditText 
          style="@style/Input" 
          android:layout_marginTop="@dimen/small_margin" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:hint="Achternaam"/> 

        </android.support.design.widget.TextInputLayout> 

        <android.support.design.widget.TextInputLayout 
         android:layout_width="match_parent" 
         app:hintTextAppearance="@style/TextInputLayoutStyle" 
         android:layout_marginTop="@dimen/small_margin" 
         android:layout_height="wrap_content"> 

         <com.Custom.saving.widgets.CustomEditText 
          style="@style/Input" 
          android:layout_marginTop="@dimen/small_margin" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:hint="Achternaam"/> 

        </android.support.design.widget.TextInputLayout> 
      </LinearLayout> 
     </android.support.v7.widget.CardView> 


     <com.Custom.saving.widgets.CustomTextView 
      android:layout_marginTop="@dimen/default_margin" 
      android:paddingRight="@dimen/activity_horizontal_margin" 
      android:paddingLeft="@dimen/activity_horizontal_margin" 
      android:layout_width="wrap_content" 
      style="@style/AopBlueParagraph" 
      android:text="@string/aop_identity_data" 
      android:layout_height="wrap_content"/> 
    </LinearLayout> 
</android.support.v4.widget.NestedScrollView> 
</android.support.design.widget.CoordinatorLayout> 

を私は画面の上部に付着バーのthatsを得たときに、コンテンツをスクロール。入力要素を持つカードで構成されるフォームです。ツールバーは、スクロール時にそのバーを移動させます。

問題は、NestedScrollviewが完全な高さを取らず、底に大きな余白が残ることです。一方、コンテンツはまだ小さなビューでスクロール可能です。時にはそれが拡大しますが、私はEditTextでテキストの編集を開始するとすぐにすべてが突然再びマージンに戻ります。

+0

削除_android:clipToPadding = "false" _ for _NestedScrollView_ – Piyush

答えて

5

NestedScrollViewandroid:fillViewport="true"を追加してください。

+1

これは既に試みられていますが、残念なことに動作しません。 –

0

ScrollViewの直系の子であるLinearLayoutandroid:fillViewport="true"ScrollViewandroid:layout_height="wrap_content"を追加します。

+2

。このソリューションでは下部の空きスペースが残ります –

関連する問題