【问题标题】:How to set dimensions of image items in GridView to fill spaces如何在 GridView 中设置图像项的尺寸以填充空间
【发布时间】:2016-04-14 12:46:43
【问题描述】:

我想根据屏幕尺寸使网格视图中的图像具有更大的尺寸,即使我使用将内容包装到图像视图并固定列数也留下空格,我通过以下方式下载图像毕加索 我的代码:

网格视图

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <GridView  xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/gridview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:verticalSpacing="0dp"
        android:horizontalSpacing="0dp"
        android:numColumns="2">
    </GridView>
</FrameLayout>

图像视图

<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/posterImage"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content">
</ImageView>

my grid view

what I want

【问题讨论】:

    标签: android xml gridview imageview picasso


    【解决方案1】:

    尝试手动添加 layout_heightlayout_width 参数,而不是 wrap_content

    <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/posterImage"
        android:layout_height="370dp"
        android:layout_width="370dp">
    </ImageView>
    

    最好将 dp 边距放入 dimen.xml 文件中。

    同样在gridView中,你应该改变match_parent而不是fill_parent

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-01-25
      • 1970-01-01
      • 1970-01-01
      • 2014-04-11
      • 1970-01-01
      • 2012-07-07
      • 1970-01-01
      相关资源
      最近更新 更多