【发布时间】:2019-05-01 14:53:57
【问题描述】:
我的recyclerview xml代码是:
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:id="@+id/blogrow"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_gravity="center_vertical"
/>
我的 CardView 代码是:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="120dp"
android:layout_height="160dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#fff"
app:cardCornerRadius="2dp"
android:layout_gravity="center"
app:cardElevation="0dp"
android:layout_marginStart="3dp"
android:layout_marginEnd="3dp"
android:layout_marginBottom="4dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/profilePostImage"
/>
</LinearLayout>
我用过gridlayout manager:
mgridLayoutManager = new GridLayoutManager(getActivity(),2);
mgridLayoutManager.setReverseLayout(true);
问题是我得到的图像有不均匀的填充。例如,左列图像的左填充较少。两列之间有大量的填充。并且在右列图像的右侧有大量的填充。 如何修复这样的列将具有均匀的填充?
【问题讨论】:
-
只在cardview中提供填充并从recyclerview和card view中删除边距
-
cardview 中的填充和 recyclerview 中的边距有效!感谢您的建议。
标签: android padding gridlayoutmanager