RecyclerView WRAP_CONTENT [英] RecyclerView wrap_content
本文介绍了RecyclerView WRAP_CONTENT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图居中RecyclerView当它的 layout_width 为 WRAP_CONTENT 无功而返
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>
当RecyclerView被给予任何明确的layout_width说200dp那么它就是中心,否则它只是左对齐。
When the RecyclerView is given any definite layout_width of say 200dp then it does center otherwise it just aligns left.
如何让RecyclerView CENTER_HORIZONTAL当其layout_width是WRAP_CONTENT?
How to make the RecyclerView center_horizontal when its layout_width is wrap_content ?
推荐答案
这是对的LayoutManager如何计算的大小有关。 这里你有一些解决方法的人有关的bug已经使用。
It is related on how the LayoutManager calculates the sizes. Here you have the related bug with some workarounds people have used.
这篇关于RecyclerView WRAP_CONTENT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文