以下是我的 xml code。我要如何写才可以把那个checkbox
移到日期和价钱(RM 5.00) 之间?我现在的是在日期下面,也就是和价钱在同一行。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dip">
<LinearLayout
android:id="@+id/thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dip"
android:orientation="vertical"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<ImageView
android:id="@+id/photo"
android:layout_width="70dp"
android:layout_height="70dp"
android:scaleType="centerCrop"
android:layout_gravity="center"/>
</LinearLayout>
<CheckBox
android:id="@+id/checkBox"
android:paddingTop="15dp"
android:paddingRight="25dp"
android:layout_width="30dp"
android:layout_height="30dp"
android:button="@drawable/xml_button"
android:background="@drawable/xml_background"
android:layout_centerVertical="true"
android:layout_alignRight="@+id/ListDate"
android:layout_alignEnd="@+id/ListDate"
android:layout_marginRight="77dp"
android:layout_marginEnd="77dp" />
<TextView
android:id="@+id/ListDate"
android:text="20 Dec"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/input_register"
android:textStyle="bold"
android:layout_alignBottom="@+id/checkBox"
android:layout_toRightOf="@+id/thumbnail"
android:layout_toEndOf="@+id/thumbnail" />
<TextView
android:id="@+id/ListAmount"
android:text="RM 5.00"
android:textSize="20sp"
android:textColor="@color/violetred"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/checkBox"
android:layout_toRightOf="@+id/thumbnail"
android:layout_toEndOf="@+id/thumbnail" />
<TextView
android:id="@+id/ListDescription"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textSize="20sp"
android:text="Description"
android:ellipsize="end"
android:layout_below="@+id/ListAmount"
android:layout_toRightOf="@+id/thumbnail"
android:layout_toEndOf="@+id/thumbnail" />
</RelativeLayout>
See if this is the case, I deleted the color, you can add it yourself:
I have never written about Android, but the object you are aligning and referencing is wrong
android:layout_alignRight="@+id/ListDate"
android:layout_alignEnd="@+id/ListDate"
You need to make CHECKBOX align based on the object of the blue square you screenshot. You are now aligning with the date component, so the date must have been moved to the back.
Simply put, the idea of layout is to refer to who, which side, and how far away.
layout_below date, then layout_marginTop a negative number