gpt4 book ai didi

android - ImageView adjustViewBounds 不适用于 fitXY

转载 作者:太空宇宙 更新时间:2023-11-03 10:42:05 24 4
gpt4 key购买 nike

我使用下面的代码来显示我的按钮

(因为我需要在按钮上添加文字,所以我不会使用ImageButton)

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/bottom001"
android:adjustViewBounds="true"
android:scaleType="fitXY"/>
</RelativeLayout>

但是ImageView在View中会有一些空白区域

我认为“fitXY”会填充 View ,但它没有

bottom

遇到这种情况我该怎么办?

感谢您的帮助:)

最佳答案

设置android:layout_width="wrap_content" 并使用LinearLayout

最后

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/test"
android:adjustViewBounds="true"
android:scaleType="fitXY"/>

详情请阅读android-imageview-scaletype-samples

FIT_XY

使用 FILL 缩放图像。在可用宽度和高度内拉伸(stretch)图片,忽略纵横比。

关于android - ImageView adjustViewBounds 不适用于 fitXY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31785847/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com