android - RecyclerLayout inside CoordinatorLayout scrollToPosition visibility -


i using coordinatorlayout appbarlayout inside , element try able scroll when recyclerview being scrolled. until that, working suposed to, problems comes when try programatically scrolltoposition of lasts positions of recyclerview. recyclerviews scroll, position tell scroll not visible (in fact, if scroll manually, visible once other element inside appbarlayout has scrolled out of screen). this code:

 <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"             android:layout_width="match_parent"             android:layout_height="match_parent">              <android.support.design.widget.appbarlayout                 android:id="@+id/app_bar_layout"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 app:elevation="0dp">                  <com.github.mikephil.charting.charts.barchart                     android:id="@+id/chart"                     android:layout_width="match_parent"                     android:layout_height="280dp"                     android:layout_below="@+id/toolbar_conso"                     android:background="@color/background_dark_grey"                     app:layout_scrollflags="scroll|enteralways" />              </android.support.design.widget.appbarlayout>              <linearlayout                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:orientation="vertical"                 app:layout_behavior="@string/appbar_scrolling_view_behavior">                  <linearlayout                     android:id="@+id/linear_total_conso"                     android:layout_width="match_parent"                     android:layout_height="wrap_content"                     android:gravity="center_horizontal"                     android:orientation="horizontal">                      <textview                         android:id="@+id/current_consumption"                         android:layout_width="wrap_content"                         android:layout_height="wrap_content"                         android:text=""                         android:textcolor="@color/graph_consumption_color"                         android:textsize="30sp" />                      <textview                         android:id="@+id/consumption_unit"                         android:layout_width="wrap_content"                         android:layout_height="wrap_content"                         android:layout_marginleft="5dp"                         android:layout_marginstart="5dp"                         android:text=""                         android:textappearance="@style/textappearance.smartlink.large"                         android:textcolor="@color/graph_consumption_color" />                 </linearlayout>                  <android.support.v7.widget.recyclerview                     android:id="@+id/recycler_view"                     android:layout_width="match_parent"                     android:layout_height="wrap_content"                     android:layout_gravity="center_horizontal" />             </linearlayout>         </android.support.design.widget.coordinatorlayout> 

and code of recyclerview:

    recyclerview = (recyclerview) view.findviewbyid(r.id.recycler_view);     recyclerview.setlayoutmanager(new linearlayoutmanager(context));     recyclerview.setadapter(adapter); 

the adapter simple text adapter........

when try scroll after receiving event service, there broadcastreceiver receives event , manage result:

    @override     public void onreceive(context context, intent intent) {             int position = intent.getextras().getint(position);             recyclerview.scrolltoposition(position);     } 

my idea think recyclerview does't understands position not visible.....

try code, collapse appbarlayout:

  @override public void onreceive(context context, intent intent) {        int position = intent.getextras().getint(position);       app_bar_layout.setexpanded(false);       recyclerview.scrolltoposition(position);   } 

Comments

Popular posts from this blog

testing - Detect whether test has failed within fixture -

AbotX : How do you create a parallel crawler that stays on and can be added to at run time from new requests -

android - Create single AAR file from multiple modules using Gradle -