2017-09-25 3 views
1

Gridviewとその下にframelayoutを持つ次のxmlがあります。 私の要件は、私は、画面をスクロールする場合は上向きに、画面全体がスクロールしなければならないですが、私だけがリストビューのスクロールについては、以下のグリッドビューとそれ以下のリストビューを持つ画面をスクロールできません

はXMLファイルです:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 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" 
android:background="@color/white" 
android:focusableInTouchMode="true" 
android:paddingBottom="@dimen/activity_vertical_margin"> 

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/time_card_header" 
    android:id="@+id/scrollView"> 
<GridView 
    android:id="@+id/timecard_grid" 
    android:layout_width="match_parent" 
    android:layout_height="130dp" 
    android:layout_margin="3dp" 
    android:fitsSystemWindows="true" 
    android:gravity="center_horizontal" 
    android:horizontalSpacing="1dp" 
    android:numColumns="3" 
    android:stretchMode="columnWidth" 
    android:verticalSpacing="1dp" /> 
    </ScrollView> 
<FrameLayout 
    android:id="@+id/timecard_reports" 
    android:layout_width="match_parent" 
    android:layout_height="fill_parent" 
    android:background="@color/white" 
    android:layout_below="@+id/scrollView"/> 
</RelativeLayout 

答えて

0

実際にGridViewコントロールとリストビューは、すでにスクロールしています。スクロールビューに上記ウィジェットを配置する必要はありません。まず、スクロールビューを削除します。 FrameLayoutを下に固定し、上記のgridviewを表示する必要があると思います。そのためには、align_parentbottom trueの線形レイアウトで最初にFrameLayoutを使用します。その後、FrameLayoutの上にグリッドビューを配置してください。これで問題は解決します。

+0

私は、画面をスクロールした場合ので、同時にグリッドビューとでframeLayoutスクロールしていますか? – saiki100

+0

私はframelayoutを別々にスクロールしたくありません。上にスクロールすると、すべての画面がgridviewと共にリストビューの最後の項目にスクロールします。 – saiki100

+0

http://www.devexchanges.info/2015/03/combining-gridview-and-listview-in-oneを見てください。 html。これはあなたの問題を解決します – dmp

0

スクロールビューの下に直線レイアウトを配置し、次にグリッドビューを配置します。

<scrollview> 
<linearlayout > 
<gridview /> 
</linearlayout > 
</scrollview> 

申し訳ありませんが、私は携帯電話からANSを与えているが、考え方は同じです。

0

GridLayoutManagerでRecyclerViewを使用し、recyclerViewのnestedScrollingEnabledをfalseに設定できます。 、代わりにScrollViewのはRecyclerViewの親としてNestedScrollViewを使用します。

private void setUpRecyclerView(View view) { 
    recyclerView = view.findViewById(id.repliesList); 
    recyclerView.setNestedScrollingEnabled(false); 
    recyclerView.setLayoutManager(new GridLayoutManager(getActivity(),numberOfColumns)); 
} 

とxmlファイル:

<android.support.v4.widget.NestedScrollView 
       android:id="@+id/nestedScroll" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 

    <RelativeLayout 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" 
     android:background="@color/white" 
     android:focusableInTouchMode="true" 
     android:paddingBottom="@dimen/activity_vertical_margin"> 

     <RecyclerView 
      android:id="@+id/timecard_grid" 
      android:layout_width="match_parent" 
      android:layout_height="130dp" 
      android:layout_margin="3dp" 
      android:fitsSystemWindows="true" 
      android:gravity="center_horizontal" 
      android:horizontalSpacing="1dp" 
      android:numColumns="3" 
      android:stretchMode="columnWidth" 
      android:verticalSpacing="1dp" /> 

     <FrameLayout 
      android:id="@+id/timecard_reports" 
      android:layout_width="match_parent" 
      android:layout_height="fill_parent" 
      android:background="@color/white" 
      android:layout_below="@+id/scrollView"/> 
     </RelativeLayout 
    </android.support.v4.widget.NestedScrollView> 
関連する問題