你只需要添加
callImage
android:layout_alignParentRight="true"
suspect_button
android:layout_width="match_parent"
和
android:layout_toLeftOf="@+id/callImage"
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
<TextView
style="?android:listSeparatorTextViewStyle"
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="@string/crime_title_label" />
<EditText
android:id="@+id/crime_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:hint="@string/crime_title_hint" />
<TextView
style="?android:listSeparatorTextViewStyle"
android:id="@+id/crime_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/crime_title"
android:text="@string/crime_details_label" />
<Button
android:id="@+id/crime_date"
android:layout_below="@+id/crime_details"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<CheckBox
android:id="@+id/crime_solved"
android:layout_below="@+id/crime_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/crime_solved_label" />
<Button
android:id="@+id/suspect_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/crime_solved"
android:layout_toLeftOf="@+id/callImage"
android:text="@string/choose_suspect" />
<Button
android:id="@+id/send_crime_report"
android:text="@string/send_crime_report"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/suspect_button" />
<ImageView
android:id="@+id/callImage"
android:layout_width="57dp"
android:layout_height="wrap_content"
android:layout_below="@id/crime_solved"
android:layout_alignBottom="@+id/suspect_button"
android:layout_alignParentRight="true"
app:srcCompat="@android:drawable/sym_action_call" />
</RelativeLayout>
在评论中回答问题。我需要添加线性布局,使图像视图对齐屏幕的右半部分
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
<TextView
style="?android:listSeparatorTextViewStyle"
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="@string/crime_title_label" />
<EditText
android:id="@+id/crime_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:hint="@string/crime_title_hint" />
<TextView
style="?android:listSeparatorTextViewStyle"
android:id="@+id/crime_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/crime_title"
android:text="@string/crime_details_label" />
<Button
android:id="@+id/crime_date"
android:layout_below="@+id/crime_details"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<CheckBox
android:id="@+id/crime_solved"
android:layout_below="@+id/crime_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/crime_solved_label" />
<LinearLayout
android:id="@+id/suspect_button_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/crime_solved"
android:weightSum="2"
android:orientation="horizontal">
<Button
android:id="@+id/suspect_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/choose_suspect" />
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
<ImageView
android:id="@+id/callImage"
android:layout_width="57dp"
android:layout_height="wrap_content"
app:srcCompat="@android:drawable/sym_action_call" />
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/send_crime_report"
android:text="@string/send_crime_report"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/suspect_button_layout" />
</RelativeLayout>
它会像这样出现