gpt4 book ai didi

android - 水平放置两个 imageView

转载 作者:行者123 更新时间:2023-11-30 04:09:52 25 4
gpt4 key购买 nike

我想水平放置两个 ImageView,但无法正确放置。

 <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"

>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" android:scaleType="fitXY">


<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/some_image" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:layout_alignBottom="@+id/imageView3"

android:src="@drawable/some_image_ontop" />



</RelativeLayout>

<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content" android:scaleType="fitXY" >


<ImageView
android:id="@+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/some_other_image" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:layout_alignBottom="@+id/imageView4"
android:src="@drawable/some_other_image_ontop" />

</RelativeLayout>
</LinearLayout>

如您所见,除了将它们水平放置之外,我还尝试将两个图像堆叠在一起。有人知道我将两张图片放在一起做错了什么吗?

最佳答案

为了使其更简单,将您的 ImageView 包含在 LinearLayout 中并将其属性设置为 android:orientation="horizo​​ntal"

例如:

...
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">


<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/some_image" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"

android:src="@drawable/some_image_ontop" />



</LinearLayout>
...

关于android - 水平放置两个 imageView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11017102/

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