相关疑难解决方法(0)

ImageView adjustViewBounds不起作用

我有一个ImageView android:layout_width=100dp,android:layout_height=wrap_contentandroid:adjustViewBounds=true

它的来源是50 x 50像素的图片.但不保留纵横比 - ImageView的高度为50px,而不是100px(即adjustViewBounds不工作).如果我有一个200x200px的图片它可以工作 - 宽度和高度是100px.此代码生成100px宽和50px高的图片,但src图像是正方形:

<?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">

    <ImageView
        android:id="@+id/photo"
        android:src="@drawable/icon"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:scaleType="fitXY"
        android:adjustViewBounds="true" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

android imageview android-imageview

38
推荐指数
2
解决办法
5万
查看次数

标签 统计

android ×1

android-imageview ×1

imageview ×1