如何将textview放在datepicker之上

时间:2012-04-25 14:01:02

标签: android datepicker textview scrollview android-linearlayout

我正在尝试使用textview和datepicker构建一个表单,例如: |日期:| | datePickerHere | 问题是我认为我有与开发者指南“相同”的代码,但它不起作用。它总是最终像: |日期:datePickerHere |

下面是代码:

    <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/scrollView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <TextView android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="15sp"
            android:text="@string/data_label"/>

        <DatePicker
            android:id="@+id/data"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>
</ScrollView>

1 个答案:

答案 0 :(得分:1)

更改

 <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content">

 <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
如果未指定“android:orientation”标记,

线性布局将默认为水平方向。您必须将其指定为垂直才能达到您想要的效果