android 9-patch 图形在图像视图中无法缩放

2024-01-08

I have

<LinearLayout android:id="@+id/LinearLayout01"
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    android:orientation="horizontal">
    <ImageView android:layout_height="wrap_content"
        android:layout_width="wrap_content" android:id="@+id/ImageView01"
        android:src="@drawable/phone80"></ImageView>
    <ImageView android:id="@+id/ImageView02"
        android:layout_height="wrap_content" android:src="@drawable/underline"
        android:layout_width="fill_parent" android:layout_gravity="fill_vertical|fill_horizontal"></ImageView>
</LinearLayout>

第一个图像是固定大小的图像,根本不应该缩放。其右侧的图像应水平缩放至最大空间。源指向有效的 .9.png 文件。不幸的是,它总是只以原始大小显示。我必须设置什么属性? ImageView 到底是正确的对象吗?

谢谢, A。


只需添加android:scaleType="fitXY"给你的ImageView。例如对于 myimage.9.png:

<ImageView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:src="@drawable/myimage"
    android:scaleType="fitXY" />
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

android 9-patch 图形在图像视图中无法缩放 的相关文章

随机推荐