android - xml 需要帮忙
怪我咯
怪我咯 2017-04-17 18:01:12
0
3
447

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

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(3)
巴扎黑

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>
Peter_Zhu

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template