[英]Align 2 images right in linear layout
我想在线性布局中将右侧的2个图像对齐。如何在2个图像之间添加空间? 这是我的代码。
Vechile.xml
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<Image
android:id="@+id/image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/img1"
android:layout_marginEnd="20dp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<Image
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:src="@drawable/img2"
android:id="@+id/image2"/>
</LinearLayout>
</LinearLayout>
将LinearLayout重力设置为右,并在ImageViews中取一些余量,如下所示:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right">
<ImageView
android:id="@+id/image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/arrow_down_black_24dp"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/image2"
android:layout_margin="5dp"
android:background="@drawable/arrow_down_black_24dp"
/>
</LinearLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.