1

我正在努力实现图中所示的东西


rounded_edittext.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- res/drawable/rounded_edittext.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:padding="10dp"
    android:shape="rectangle" >

    <solid android:color="#FFFFFF" />

    <corners
        android:bottomLeftRadius="10dp"
        android:bottomRightRadius="10dp"
        android:topLeftRadius="10dp"
        android:topRightRadius="10dp" />

</shape>

search_page.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#C0C0C0"
    android:orientation="vertical" >

    <TableRow
        android:id="@+id/row1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="City" />

        <EditText
            android:id="@+id/editText1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/rounded_edittext"
            android:ems="10"
            android:padding="5dip" />
    </TableRow>

    <TableRow
        android:id="@+id/row1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Date" />

        <EditText
            android:id="@+id/editText2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/rounded_edittext"
            android:ems="10"
            android:inputType="date"
            android:padding="5dip" >

            <requestFocus />
        </EditText>
    </TableRow>

    <TableRow
        android:id="@+id/row1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Type" />

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Breakfast" />

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Lunch" />

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Dinner" />
    </TableRow>

    <TableRow
        android:id="@+id/row1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center" >

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="Search" />
    </TableRow>

</LinearLayout>

我有如下输出::

在此处输入图像描述


如何修改我的xml,以便我可以实现如下::

在此处输入图像描述

我正在尝试获得与上面完全相同的布局

  • 我也试图使用一个edittext日期,如second pic我所达到的那样
  • 我也想把所有的东西都放在盒子行中,如上所示

有任何想法吗 ?

希望我清楚!

4

1 回答 1

1
try this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout 
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:weightSum="1"
    >
    <TextView 
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="City"
        android:layout_weight=".25"/>
    <EditText 
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_weight=".75"/>
</LinearLayout>

<View 
    android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:background="@android:color/black"/>

<LinearLayout 
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:weightSum="1"
    >
    <TextView 
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="date"
        android:layout_weight=".25"/>
    <EditText 
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_weight=".25"/>

    <EditText 
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_weight=".25"/>

    <EditText 
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_weight=".25"/>

    <EditText 
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_weight=".25"/>
</LinearLayout>

<View 
    android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:background="@android:color/black"/>

 <LinearLayout 
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:weightSum="1"
    >
    <TextView 
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="type"
        android:layout_weight=".25"/>
    <Button 
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:text="breakfast"
        android:textSize="10sp"
        android:layout_weight=".25"/>

    <Button 
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:text="lunch"
         android:textSize="10sp"
        android:layout_weight=".25"/>

    <Button 
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:text="dinner"
         android:textSize="10sp"
        android:layout_weight=".25"/>

</LinearLayout>

<View 
    android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:background="@android:color/black"/>

<Button 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:text="Search"/>

于 2013-10-04T10:47:43.937 回答