1

我有一个 ListView,我在其中显示带有缩略图和屏幕填充图片的类似 Instagram 的提要。我对个人资料缩略图和主图片都使用了 Volley NetworkImageView,并且我的占位符与从服务器下载的图像的大小完全相同。

缩略图:128x128 图片:612x612

我的问题是图像加载后,它们不再填满屏幕,似乎凌空正在调整它们的大小,导致布局突然改变。缩略图的布局也略有变化(填充)(见截图)。

任何想法可能是错误的,我可以做些什么来解决这个问题?

编辑似乎一旦加载,布局就会强制图像变小,如果我设置android:scaleType:centerCrop,图像将采用全宽但在高度上被裁剪。如何强制图像在保持高度的同时满足约束全宽?

在此处输入图像描述

和xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    android:orientation="vertical"
    android:descendantFocusability="blocksDescendants" >


    <RelativeLayout 
        android:id="@+id/header_layout"
        android:layout_width="match_parent"
        android:layout_height="?android:attr/listPreferredItemHeight"
        android:padding="6dip" >

        <com.android.volley.toolbox.NetworkImageView
            android:id="@+id/thumbnail"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_alignParentBottom="false"
            android:layout_alignParentTop="true"
            android:layout_marginRight="6dip"
            android:adjustViewBounds="true" 
            android:src="@drawable/holder_spot_thumbnail" />

        <TextView
            android:id="@+id/header"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_alignWithParentIfMissing="false"
            android:layout_toRightOf="@id/thumbnail"
            android:clickable="true"
            android:gravity="center_vertical"
            android:text="" >
        </TextView>

        <TextView
            android:id="@+id/place_date"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/header"
            android:layout_toRightOf="@id/thumbnail"
            android:layout_alignWithParentIfMissing="false"
            android:gravity="center_vertical"
            android:text=""
            android:textSize="12sp" ></TextView>



    </RelativeLayout>

    <com.android.volley.toolbox.NetworkImageView
        android:id="@+id/picture"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true" 
        android:src="@drawable/holder_feed_image" 
        android:padding="6dip"/>


   </LinearLayout>
4

0 回答 0