Issue
I am trying to center a RecyclerView when its layout_width is wrap_content without success
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_schemes"
android:scrollbars="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
When the RecyclerView is given any definite layout_width of say 200dp then it does center otherwise it just aligns left.
How to make the RecyclerView center_horizontal when its layout_width is wrap_content ?
Solution
It is related on how the LayoutManager calculates the sizes. Here you have the related bug with some workarounds people have used.
NOTE: With the release 23.2 of the support library now the wrap content is supported, so looks like they fixed it. You can checkout the changelog here
Answered By - droidpl
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.