gpt4 book ai didi

android - 对齐右下角的图像

转载 作者:太空宇宙 更新时间:2023-11-03 12:43:03 25 4
gpt4 key购买 nike

我正在使用相对布局将一个较小的图像叠加在一个较大的图像之上。我希望较小图像的右下角与较大图像的 B-R 角重合。我在我的布局 XML 中使用边距参数(以倾角指定测量值)但这似乎不适用于所有设备和分辨率 - 在某些情况下,小图像从边框移动 4-5 像素。

是否可以在没有像素值的情况下指定较小图像的位置? IE。用重力什么的?

最佳答案

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/big_image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/bigimage"/>
<ImageView
android:id="@+id/little_image"
android:layout_width="50dip"
android:layout_height="50dip"
android:layout_alignRight="@id/big_image"
android:layout_alignBottom="@id/big_image"
android:src="@drawable/littleimage"/>
</RelativeLayout>

RelativeLayout 的好处是您可以使用相对 位置和尺寸,而不是使用特定的倾角或像素。在上面的例子中,我只是使用了 android:layout_align* 参数,以确保两个图像对齐。请记住,我为小图片设置了特定尺寸,但您可以更改它以满足您的需要。

关于android - 对齐右下角的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4079410/

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