
这是我的代码:
final GrIDLayoutManager layoutManager = new GrIDLayoutManager(this,3); layoutManager.setorIEntation(linearlayoutmanager.VERTICAL); recyclerVIEw.setLayoutManager(layoutManager); recyclerVIEw.setAdapter(adapter);
这是活动的xml:
<relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"xmlns:tools="http://schemas.androID.com/tools" androID:layout_wIDth="match_parent"androID:layout_height="match_parent" androID:paddingleft="@dimen/activity_horizontal_margin"androID:paddingRight="@dimen/activity_horizontal_margin"androID:paddingtop="@dimen/activity_vertical_margin"androID:paddingBottom="@dimen/activity_vertical_margin"tools:context="com.adriagate.adriagateonlineandroID.activitIEs.ImagesActivity"><fragment xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:tools="http://schemas.androID.com/tools" androID:ID="@+ID/fragmentimagesheader" androID:name="com.adriagate.adriagateonlineandroID.fragments.Imagesheader" tools:layout="@layout/fragment_images_header" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" ></fragment><fragment xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:tools="http://schemas.androID.com/tools" androID:ID="@+ID/fragmentimagesGrID" androID:name="com.adriagate.adriagateonlineandroID.fragments.ImagesList" tools:layout="@layout/fragment_images_List" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" ></fragment> </relativeLayout>
请注意,此布局有一个名为fragmentimagesGrID的重要片段,它具有以下布局:
<FrameLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"xmlns:tools="http://schemas.androID.com/tools" androID:layout_wIDth="match_parent"androID:layout_height="match_parent"tools:context="com.adriagate.adriagateonlineandroID.fragments.ImagesList"> <androID.support.v7.Widget.RecyclerVIEw androID:ID="@+ID/recycler_vIEw_images" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" tools:Listitem="@layout/recycler_vIEw_images_one_row" >
</FrameLayout>
这是我在Recycler视图中的一个元素的布局:
<?xml version="1.0" enCoding="utf-8"?> <FrameLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:orIEntation="vertical" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" xmlns:tools="http://schemas.androID.com/tools" ><ImageVIEw androID:ID="@+ID/imageVIEwImagesAllOneRow" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_gravity="center_horizontal" tools:src="@drawable/slika_200_200" /> </FrameLayout>解决方法 看起来它发生是因为您的图像有不同的大小.
将项目更改为linearLayout并将其布局高度和宽度设置为match_parent.设置gravity =“center”(线性布局).
另一个问题是androID:layout_height =“wrap_content”.将height属性设置为wrap_content时,RecyclerVIEw无法正常工作.如果您仍想将RecyclerVIEw与wrap_content一起使用,则可以使用 this解决方案 总结
以上是内存溢出为你收集整理的在RecyclerView中的android – GridLayoutManager 3列全部内容,希望文章能够帮你解决在RecyclerView中的android – GridLayoutManager 3列所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)