android - RecyclerView LinearLayout manager always returns -1 in landscape mode - findLastCompletelyVisibleItemPosition() -


i'm using findlastcompletelyvisibleitemposition() determine last visible item in recyclerview.

here code snippet of how i'm setting layout:

    mrecyclerview.sethasfixedsize(true);     linearlayoutmanager mlayoutmanager = new linearlayoutmanager(getcontext());     mrecyclerview.setlayoutmanager(mlayoutmanager); 

layout xml:

<android.support.v4.widget.swiperefreshlayout  xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/swipe_container"     android:layout_width="match_parent"     android:layout_height="match_parent">  <framelayout     android:layout_width="match_parent"     android:layout_height="match_parent">      <android.support.v7.widget.recyclerview         android:id="@+id/message_list"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:background="@android:color/white"         android:paddingbottom="@dimen/footer_progress_bar"         android:paddingtop="16dp"         android:scrollbars="vertical" />      <progressbar         android:id="@+id/progress_bar"         android:layout_width="50dp"         android:layout_height="50dp"         android:layout_gravity="center"         android:visibility="gone" />      <progressbar         android:id="@+id/footer_progress_bar"         android:layout_width="@dimen/footer_progress_bar"         android:layout_height="@dimen/footer_progress_bar"         android:layout_gravity="center|bottom"         android:visibility="gone" />  </framelayout> </android.support.v4.widget.swiperefreshlayout> 

in portrait mode, works fine , returns right position.

however in landscape mode, position returned -1.

my question is:

does know why happens?

how can override return right position?

or can recommend solution right position of last item in landscape?

the "-1" seeing recyclerview.no_position return code indicating there no visible position in recyclerview in landscape mode. "completely visible" means entire view including decorations , margins (top/bottom margins vertical orientation , left/right horizontal orientations) visible. may see of data, single pixel sneaking off out of view. take @ findlastcompletelyvisibleitemposition() , invocation of findonevisiblechild() here.

double check have 100% visible position in recyclerview outlined above. show margins in developer mode, etc. else more mysterious going on if verify there @ least 1 visible position.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -