我有一个使用GridLayoutManager
的垂直RecyclerView
。我希望每一列都居中,但所有列都从左侧开始。在下面的图片中,你可以看到我在说什么。我使用丑陋的配色方案来说明列和背景。绿色是RecyclerView
中每个项目的背景,红色是RecyclerView
本身的背景:
我使用以下命令进行设置:
mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));
下面是column_item.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="120dp"
android:layout_height="180dp"
android:orientation="vertical"
android:padding="4dp">
<ImageView
android:id="@+id/movie_column_photo"
android:layout_width="80dp"
android:layout_height="120dp"/>
<TextView
android:id="@+id/movie_column_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
下面是recyclerview:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/company_details_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
https://stackoverflow.com/questions/38624843
复制相似问题