使用RelativeLayout
是正确的,请尝试以下
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<TextView
android:id="@+id/tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginRight="16dp"
android:layout_toLeftOf="@+id/btn"
android:text="Hello World!asdfasdfasfasdfdasfsadfsfsafasfasfasdasdasdaas" />
<Button
android:id="@id/btn"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="test"
android:layout_centerVertical="true"/>
</RelativeLayout>
结果:
我不认为你可以让你的第三个展示的文字+按钮。包装的TextView制作一个矩形,所以没有“间隙”来放置一个按钮 –