【发布时间】:2020-01-17 18:30:31
【问题描述】:
我在查看器项目内有一个回收器视图,用于很好地显示多达 5 个图像以及一些其他文本。它工作得很好,只是图像看起来非常小,我不确定我哪里出错了。
主视图项目布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="14dp">
<TextView
android:id="@+id/feedItem_txtTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:layout_marginTop="14dp"
android:textColor="@color/dark_gray"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/feedItem_rvImageGrid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
<View
android:layout_marginTop="5dp"
android:layout_width="match_parent"
android:layout_height="15dp"
android:background="@color/very_light_gray"/>
</LinearLayout>
</LinearLayout>
图像网格视图项目:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/feedItemImage_ivImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
</LinearLayout>
我用来将网格绑定到 recyclerview 的代码
_layoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.Vertical);
_feedItemImageAdapter = new FeedItemImageAdapter(_imageUrlsVisible, _imageUrlsFull);
_rvImageGrid.SetAdapter(_feedItemImageAdapter);
_rvImageGrid.SetLayoutManager(_layoutManager);
不确定您还想看什么,如果我需要提供更多代码示例,请告诉我,我不知道自己做错了什么。
【问题讨论】:
-
对不起,我无法重现这个问题,您能否分享一个基本的演示,以便我们进行测试?
-
早上我可以使用我的工作计算机时,我将着手获取一个示例项目
标签: xamarin.android staggeredgridlayoutmanager