2017-03-23 19 views
-1

ボトムシートをListViewとともに使用しようとしていますが、2つ目の問題に直面しています。リストビューは、ボトムシートからすべてのスペースを占めていない、マッチする親は動作していない、第2です。リストビューのスクロールは実際には機能しません。スクロールしようとすると、通常のスクロールの代わりに少ししかスクロールせず、スクロールするとリストをスクロールせずに終了します。ここで Gif of the problemリストビューが動作しないAndroidボトムシート

はXMLです:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true"> 

    <fragment xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:map="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/map" 
    android:name="com.google.android.gms.maps.SupportMapFragment" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.example.abili.agriexport2.MapsActivity" /> 

    <android.support.v4.widget.NestedScrollView 
     android:id="@+id/bottom_sheet" 
     android:layout_width="match_parent" 
     android:layout_height="350dp" 
     android:background="?android:attr/windowBackground" 
     android:clipToPadding="true" 
     app:layout_behavior="android.support.design.widget.BottomSheetBehavior"> 


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

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:background="@color/colorPrimary" 
       android:orientation="horizontal"> 

       <TextView 
        android:id="@+id/textView11" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_weight="1" 
        android:padding="16dp" 
        android:text="Direções" 
        android:textColor="@color/colorWhite" 
        android:textSize="24sp" /> 

       <ImageButton 
        android:id="@+id/closeBottomSheet" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_weight="5" 
        android:background="@null" 
        app:srcCompat="@drawable/mr_ic_close_dark" /> 

      </LinearLayout> 

      <ListView 
       android:id="@+id/listaDirecoes" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" /> 

     </LinearLayout> 
    </android.support.v4.widget.NestedScrollView> 

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

は、任意の助けに感謝:)

答えて

2

があなたのNestedScrollView


android:fillViewport="true" 

を追加しよう0

他の問題、私は一度この方法を使用するために:

yourLV.setOnScrollListener(new ListView.OnScrollListener() { 
      @Override 
      public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { 

      } 

      @Override 
      public void onScrollStateChanged(AbsListView arg0, int arg1) { 
       if (listIsAtTop(yourLV)) { 
        yourLV.setOnTouchListener(null); 
       } else { 
        yourLV.setOnTouchListener(new View.OnTouchListener() { 
         @Override 
         public boolean onTouch(View v, MotionEvent event) { 
          // Disallow the touch request for parent scroll on touch of child view 
          v.getParent().requestDisallowInterceptTouchEvent(true); 
          return false; 
         } 
        }); 
       } 
      } 
     }); 

そして

public static boolean listIsAtTop(ListView listView) { 
     if(listView.getChildCount() == 0) return true; 
     return listView.getChildAt(0).getTop() == 0; 
    } 
+0

をよく固定問題Nº1、おかげでたくさん、あなたは問題のnº2を修正するための任意のアイデアを持っていますか? – alb

+0

@alb編集を確認して、うまくいきたいです! –

+0

ノープは動作しませんでした – alb

関連する問題