2015-09-04 38 views
5

したがって、垂直なScrollViewの中に水平なRecyclerViewがあります。私のレイアウトの中のすべてがうまく表示され、それはすべて私が望む方向にスクロールし、スムーズにそれを行います。垂直方向の水平RecyclerView ScrollView

唯一の問題は、RecyclerViewがScrollViewの他のコンテンツの下にあり、RecyclerViewが部分的に表示されているときに、起動時に画面の下部にRecyclerViewの下部が表示されることです。これは、RecyclerViewの上のコンテンツが画面からプッシュされることを意味します。

なぜこのようなことが起こるのか、誰にどのように修正できるのか、誰にも分かりますか?

ここで説明したような単純なレイアウトがあります。 RecyclerViewを作成する必要はありませんが、それでもやります。

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

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

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="500dp" 
      android:background="#fff"/> 

     <android.support.v7.widget.RecyclerView 
      android:layout_width="match_parent" 
      android:layout_height="200dp" 
      android:background="#000"/> 

    </LinearLayout> 

</ScrollView> 
+0

チェックこのhttps://github.com/lucasr/twoway-view/:

以下は、私は元の質問に提供されたコードのサンプルの修正です。 – Raghunandan

+0

私はTwoWayViewについて知っているから、それは本当に私の質問には関係ありませんが、とにかく感謝します。 –

答えて

6

は、この問題は、意図したとおり、それが働いているグーグルによると、ここでIssue - 81854

Googleに報告されたが判明します。問題は、RecyclerViewがfocusableInTouchModeをtrueに設定しているという事実です。問題を解決するために、ScrollViewの一番上のビューでfocusableInTouchModefocusableをtrueに設定しました。

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

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

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="500dp" 
      android:background="#fff" 
      android:focusableInTouchMode="true" 
      android:focusable="true"/> 

     <android.support.v7.widget.RecyclerView 
      android:layout_width="match_parent" 
      android:layout_height="200dp" 
      android:background="#000"/> 

    </LinearLayout> 

</ScrollView> 
+0

ScrollViewの一番上のビューで 'focusableInTouchMode'と' focusable'をtrueに設定したとします。しかし、コードで私は何か違うものを見ます。どうか明らかにしてください。 –

+0

@ Parsi申し訳ありません。 ScrollViewには子が1つしかないので、私はScrollViewの子の一番上のビューを意味していました。 –

+0

私はそれを得ないでください。ありがとうございました。いいえ言及: –

関連する問題