簡體   English   中英

ImageView里面recyclerView寬高布局

[英]ImageView inside recyclerView width and height layout

我有一個像whatsapp這樣的聊天應用程序。 我想展示我在內部存儲中的幾張圖像。 因此,對於該圖像,我唯一知道的是我可以找到它的路徑。 但是,在 image_item 的 xml 布局中,我必須設置 imageView 的寬度和高度。

<ImageView
            android:id="@+id/rcvImage"
            android:layout_width="280dp"
            android:layout_height="280dp"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="32dp"
            android:adjustViewBounds="true"
            android:maxWidth="320dp"
            android:maxHeight="320dp"
            android:minWidth="150dp"
            android:minHeight="150dp"
            android:scaleType="centerCrop"
            android:src="@drawable/default_img"
            tools:ignore="ContentDescription" />

我如何設置這些值,以便我可以擁有縱向和橫向圖像,但不會在 recyclerview 滾動中產生滯后

您可以設置wrap_contentadjustViewBounds

<ImageView
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:adjustViewBounds="true"
    android:src="@drawable/test"/>

此外, scaleType 可以幫助調整圖像大小

android:scaleType="fitStart"

https://developer.android.com/reference/android/widget/ImageView.ScaleType

暫無
暫無

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

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