簡體   English   中英

listView中不同的ImageView大小

[英]Different ImageView size in a listView

我有一個帶有ImageView和EditText的自定義listview,我的問題是,對於不同的圖像,imageview的大小是不同的,就像在照片中一樣。 如何確定所有圖像的尺寸相同?

listView的圖像

這是我的XML代碼:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="1">

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="150px"
    android:layout_height="150px"
    android:adjustViewBounds="true"
    android:layout_weight="0.1"
    android:scaleType="fitXY"
    android:layout_marginBottom="1dp"/>

要處理不同的長寬比圖像,最好的方法是在布局中選擇一個長寬比,然后對圖像進行中心裁剪,以使其占據可用空間。

<ImageView
    android:layout_width="160dp"
    android:layout_height="90dp"
    android:scaleType="centerCrop" />

為了獲得更好的尺寸,請為每個包含ImageviewEdittext的行創建線性布局。 您已將ScaleType設置為fitXY ,這很好。 現在使用dpfill_parent作為Imageview的大小。

(代表OP張貼)

我已經解決了-我只需刪除此android:layout_weight="0.1"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM