2016-09-25 9 views
0

グリッドビューはスクロールしません。グリッドビューには10個のアイテムがありますが、6個だけのショーと、カットオフ時の下部にあるアイテムがいくつかあります。ここでnestedscrollviewに埋め込まれたグリッドビューをスクロールできません

は、GridViewのレイアウトです:

<?xml version="1.0" encoding="utf-8"?> 

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:id="@+id/appbar_layout" 
    android:layout_height="@dimen/app_bar_height" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapsing_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:contentScrim="?attr/colorPrimary" 
     app:expandedTitleMarginStart="@dimen/expanded_toolbar_title_margin_start" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

     <ImageView 
      android:id="@+id/image_view" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:scaleType="centerInside" 
      android:src="@drawable/yelp" 
      app:layout_collapseMode="parallax" 
      app:layout_collapseParallaxMultiplier="0.7" /> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      app:layout_collapseMode="pin" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
      app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> 

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

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

<android.support.v4.widget.NestedScrollView 
    android:layout_width="match_parent" 
    android:id="@+id/nestedscrollview" 
    android:layout_height="match_parent" 
    android:fillViewport="true" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

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


     <GridView 
      android:id="@+id/grid" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:columnWidth="100dp" 
      android:gravity="center" 
      android:listSelector="#00000000" 
      android:numColumns="auto_fit" 
      android:stretchMode="columnWidth" 
      /> 

     <ProgressBar 
      android:id="@+id/progressBar1" 
      style="?android:attr/progressBarStyleLarge" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" /> 

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

、ここでは、問題の写真2枚があります。私が上にスクロールすると、それは妖精のイメージをプッシュアップしますが、それはグリッドビューでネストされたスクロールをしません、なぜですか?

enter image description here

enter image description here

はUPDATE: また、私はこれをやってみました:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 
      mGridView.setNestedScrollingEnabled(true); 
     } 

、それはAPIのロリポップに取り組んで始まりました。しかし、私はそれも古いデバイスで実行する必要があります。なぜロリポップの前にデバイスでスクロールしないのですか?

答えて

1

GridViewではなく、GridLayoutでRecyclerViewを使用することができます。次に、ネストされたスクロールを無効にするには、前のロリポップバージョンで行うことができます。

1

まず、私はGridViewがスクロール動作をビルドしていることを明確にすることができます。では、なぜNestedScrollViewを使用しますか?ご覧のとおり、GridViewのドキュメントを参照してください。 GridViewは、それとの競合である理由です

https://developer.android.com/guide/topics/ui/layout/gridview.html

関連する問題