Android 如何使用间距将一个视图与另一个视图的右侧对齐?
我想将我的Android 如何使用间距将一个视图与另一个视图的右侧对齐?,android,Android,我想将我的视图与另一个视图的右侧对齐,但它们之间有一定的间距。我想用规则的右边来做这个。我搜索了很多,但找不到合适的解决方案。第二个视图可以使用margin\u left属性或paddingLeft属性,如下所示: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match
视图
与另一个视图
的右侧对齐,但它们之间有一定的间距。我想用规则的右边来做这个。我搜索了很多,但找不到合适的解决方案。第二个视图可以使用margin\u left属性或paddingLeft属性,如下所示:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="@+id/View1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello" />
<TextView
android:id="@+id/View2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/View1"
android:layout_marginLeft="10dp"
android:text="World" />
</RelativeLayout>
第二个视图可以使用margin\u left属性或paddingLeft属性,如下所示:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="@+id/View1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello" />
<TextView
android:id="@+id/View2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/View1"
android:layout_marginLeft="10dp"
android:text="World" />
</RelativeLayout>
使用android:toRightOf=“@+id/other_视图”使用android:toRightOf=“@+id/other_视图”