search

Home  >  Q&A  >  body text

android - xml 需要帮忙

以下是我的 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>

怪我咯怪我咯2772 days ago446

reply all(3)I'll reply

  • 巴扎黑

    巴扎黑2017-04-17 18:03:12

    See if this is the case, I deleted the color, you can add it yourself:

    <?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:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_alignParentTop="true"
            android:orientation="vertical"
            android:padding="3dip">
    
            <ImageView
                android:id="@+id/photo"
                android:layout_width="70dp"
                android:layout_height="70dp"
                android:layout_gravity="center"
                android:scaleType="centerCrop"/>
        </LinearLayout>
    
    
        <TextView
            android:id="@+id/ListDate"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_toEndOf="@+id/thumbnail"
            android:layout_toRightOf="@+id/thumbnail"
            android:text="20 Dec"
            android:textStyle="bold"/>
    
        <TextView
            android:id="@+id/ListAmount"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/ListDate"
            android:layout_toEndOf="@+id/thumbnail"
            android:layout_toRightOf="@+id/thumbnail"
            android:text="RM 5.00"
            android:textSize="20sp"/>
    
        <TextView
            android:id="@+id/ListDescription"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/ListAmount"
            android:layout_toEndOf="@+id/thumbnail"
            android:layout_toRightOf="@+id/thumbnail"
            android:ellipsize="end"
            android:singleLine="true"
            android:text="Description"
            android:textSize="20sp"/>
    
        <LinearLayout
            android:id="@+id/ll_cb"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/ListAmount"
            android:layout_alignParentRight="true"
            android:layout_alignTop="@+id/ListDate"
            android:gravity="center_vertical">
    
            <CheckBox
                android:id="@+id/checkBox"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_marginEnd="77dp"
                android:layout_marginRight="77dp"/>
    
        </LinearLayout>
    
    
    </RelativeLayout>

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 18:03:12

    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.

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 18:03:12

    layout_below date, then layout_marginTop a negative number

    reply
    0
  • Cancelreply