gpt4 book ai didi

android - 使用 "match_parent"将图像对齐到顶部

转载 作者:行者123 更新时间:2023-11-30 03:35:07 24 4
gpt4 key购买 nike

我的申请有问题。我有一张横跨整个屏幕 (ImageView) 的图像,其中包含以下 xml 代码:

    <ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:src="@drawable/achtergrond"
android:scaleType="fitCenter" />

我的问题是图像位于 imageview 本身的中心。它需要居中,如下图所示:

enter image description here左边的图片是我的,中间是图片。右边是我想要的,图像应该在整个布局中,我需要将我的图像设置为 match_parent 以将其填充为背景(我没有将其设置为背景,因为它会被拉伸(stretch))。

我希望我遗漏了一些明显的东西!感谢您提前帮助我!

最佳答案

<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/achtergrond"
android:scaleType="fitStart" />

关于android - 使用 "match_parent"将图像对齐到顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16741074/

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