2017-01-27 12 views
0

これはRecyclerViewでは難しいかどうかはわかりませんが、簡単な方法があると思っていましたが、いくつかの問題があります。 私はアクティビティに対してRecyclerViewを持っています。アクティビティに行くと、アイテムにスクロールします。十分に良いと思われる。しかし、私の問題は、一度に5つのアイテムしかスクリーンに収まらず、6つのアイテムがあり、5番目または4番目のアイテムにスクロールすると、リサイクラビューは少しスクロールしますが、それはRecyclerView境界によって制限されているので、要素にスクロールします。Android RecyclerViewの上にスクロールして項目を置く

RecyclerViewの4番目または5番目の項目にスクロールすると、ビューの一番上に配置され、最後の項目の下にある領域が背景色になります通常のビュー、私は正常にバックアップをスクロールできますか? 私は自分自身を正しく説明してくれることを願っています。これを簡単に行うことができ、私はXMLセットアップやコード設定で間違いを犯したのかどうかはわかりません。

<merge xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:visibility="gone"> 

<RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

    <include 
      android:id="@+id/timelineSwitcherView" 
      layout="@layout/view_timeline_view_switcher"/> 

    <ViewAnimator 
      android:id="@+id/viewAnimator" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_below="@+id/timelineSwitcherView"> 

     <RelativeLayout 
       android:id="@+id/timeLineRelativeLayout" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:background="@color/lighterBlue"> 

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

       <android.support.v7.widget.RecyclerView 
         android:id="@+id/timeLineRecyclerView" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content"/> 

      </android.support.v4.widget.SwipeRefreshLayout> 

     </RelativeLayout> 

これに関する助けと指導をお待ちしております。

答えて

1

あなたは

mRecyclerview.scrollTo(x,y); 
    mRecyclerview.scrollToPosition(); 

またはより良いを使用する必要があります。

mRecyclerview.smoothScrollBy(x , y);   
    mRecyclerview.smoothScrollToPosition(List item position); 

ですから、Y位置、またはリスト内の子の位置を取得する必要があります。

+0

動作するのはscrollToPositionだけです。それはトップに位置していないところで言及した問題を引き起こすので、それは実際に焦点が合っているようには見えません。 ScrollTo、smoothScrollBy、smoothScrollToPositionは私のためにまったくスクロールしません。だから、私はXML設定が間違っているかもしれないと思ったのですか?他の設定がありません。 – goodgamerguy

+0

私は自分のLinearLayoutマネージャを作成してスムーズなスクロールをオーバーライドしようとしました。それは今スムーススクロールが、それはトップに表示されませんが、それはまだ中央の外に表示される同じ問題 – goodgamerguy

関連する問題