sebbl.sche
sebbl.sche

Reputation: 321

Using DatePicker and TimePicker in same layout

I'm trying to use one date picker and two time picker in the same layout, but only the first one in layout is being displayed. I'm sure something must be wring with my layout but haven't found the error yet.

layout.xml

<?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:background="#B5B5B5"
    android:orientation="vertical" >

    <include layout="@layout/actionbar_layout" />

    <LinearLayout
        android:id="@+id/new_conference_date"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#f8f9fe"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/new_conference_date_label"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="date:"
            android:textColor="#000000" />

        <TextView
            android:id="@+id/new_conference_date_value"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text=""
            android:textColor="#000000" />

        <Button
            android:id="@+id/new_conference_date_picker"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/new_conference_start"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#f8f9fe"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/new_conference_start_label"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="start:"
            android:textColor="#000000" />

        <TextView
            android:id="@+id/new_conference_start_value"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text=""
            android:textColor="#000000" />

        <Button
            android:id="@+id/new_conference_start_picker"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/new_conference_end"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#f8f9fe"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/new_conference_end_label"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="end:"
            android:textColor="#000000" />

        <TextView
            android:id="@+id/new_conference_end_value"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text=""
            android:textColor="#000000" />

        <Button
            android:id="@+id/new_conference_end_picker"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="" />
    </LinearLayout>

</LinearLayout>

Upvotes: 0

Views: 312

Answers (2)

Rafael T
Rafael T

Reputation: 15679

try this one:

<?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:background="#B5B5B5"
android:orientation="vertical" >

<include layout="@layout/actionbar_layout" />

<LinearLayout
    android:id="@+id/new_conference_date"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#f8f9fe"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/new_conference_date_label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="date:"
        android:textColor="#000000" />

    <TextView
        android:id="@+id/new_conference_date_value"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=""
        android:textColor="#000000" />

    <Button
        android:id="@+id/new_conference_date_picker"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="" />
</LinearLayout>

<LinearLayout
    android:id="@+id/new_conference_start"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#f8f9fe"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/new_conference_start_label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="start:"
        android:textColor="#000000" />

    <TextView
        android:id="@+id/new_conference_start_value"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=""
        android:textColor="#000000" />

    <Button
        android:id="@+id/new_conference_start_picker"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="" />
</LinearLayout>

<LinearLayout
    android:id="@+id/new_conference_end"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#f8f9fe"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/new_conference_end_label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="end:"
        android:textColor="#000000" />

    <TextView
        android:id="@+id/new_conference_end_value"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=""
        android:textColor="#000000" />

    <Button
        android:id="@+id/new_conference_end_picker"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="" />
</LinearLayout>

I just changed inner LinearLayouts height to wrap_content

Upvotes: 1

Ion Aalbers
Ion Aalbers

Reputation: 8030

You have three LinearLayout with match_parent in layout_width without a weight.

Try adding the next line to those LinearLayout's

        android:layout_weight="1"

Upvotes: 0

Related Questions