1

Universal Image Loader を使用して、いくつかの画像を取得し、リストビューに表示しています。レイアウトが正しく表示されずに困っています。画像が幅の 25% を超えないようにしたいのですが、これは Eclipse のグラフィカル レイアウト ビューでは問題ないように見えますが、画像をダウンロードするとフル サイズで表示され、大きすぎます。maxwidth全幅がどうなるかわからないので、使用を避けたいと思っていました。

これは私のレイアウトxmlです

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:padding="10dp"
android:weightSum="100" >

<ImageView
    android:id="@+id/imgIcon"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_gravity="center_vertical"
    android:layout_weight="25"
    android:contentDescription="@string/offerImage"
    android:paddingRight="10dip"
    android:src="@drawable/ic_launcher" />

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="75"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/txtTitle"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:layout_marginTop="5dp"
        android:text="tempString"
        android:textColor="#ffffffff"
        android:textSize="18sp" />

    <TextView
        android:id="@+id/txtRetailer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Business name"
        android:textColor="#ffffffff"
        android:textSize="16sp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/txtDistance"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:text="99.99 miles"
        android:textColor="#ffffffff"
        android:textSize="12sp"
        android:textStyle="bold" />
</LinearLayout>

4

3 に答える 3

2

UIL で使用される ImageView のサイズにも問題がありましたが、これが役に立ちました。

iv.setAdjustViewBounds(true);

試してみる価値があるかもしれません。

于 2013-04-12T15:19:30.437 に答える
1

解決策は、との両方のlayout_width値をに設定することです。 未使用スペースに対してのみ機能するため、画像が大きすぎる場合は空きスペースがありません。0dipImageViewLinearLayoutlayout_weight

于 2013-04-12T15:59:36.547 に答える
0

あなたのxmlファイルでこれをimageViewタグに追加してくださいこれを追加してください

android:scaleType="fitXY"
于 2013-04-12T15:24:58.793 に答える