【发布时间】:2016-01-18 19:59:48
【问题描述】:
我使用的是简单的RecyclerView - GridLayoutManager,第一行比其他行更大。
这是带有RecyclerView的布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/single_gallery_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:layout_marginTop="50dp"/>
</RelativeLayout>
这里是gridLayoutManager的创建:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mParentView = inflater.inflate(R.layout.fra_gallery_single, null);
mRecyclerView = (RecyclerView) mParentView.findViewById(R.id.single_gallery_list);
mAdapter = new SingleGalleryAdapter(getActivity(), ((MainActivity)getActivity()).getSelectedGalleryData().getPhotos());
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.main_background_color));
mRecyclerView.addItemDecoration(new AppItemDecorator(3, 7));
mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 3));
return mParentView;
}
这是我的项目布局的样子:
<ImageView
android:id="@+id/single_item_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/img_gallery_1"/>
</LinearLayout>
我有非常简单的适配器。 这是我的屏幕的图片:
有什么建议为什么我的第一行比其他人大吗?
【问题讨论】:
标签: android android-recyclerview