0

我試圖用textview和datepicker來建立一個窗體,例如: | Date:| | | datePickerHere | 問題是我認爲我有與開發者指南「相同」的代碼,但它不工作。它總是結束如: |日期:datePickerHere |如何把textview放在日期選擇器上

繼承人的代碼:

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

變化

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

線性佈局將默認爲水平方向,如果你不指定 「機器人:方向」標籤。你必須指定它爲垂直,以達到你想要的效果