2016-07-04 89 views
1

我有一個適合屏幕的主要佈局,然後我希望它向下滾動以顯示按鈕, 我試圖刪除fillviewport,但它然後崩潰視圖, 我什至做了線性佈局wrap_content,它也是一樣的,摺疊視圖我的scrollView不滾動?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_marginBottom="8dp" 
      android:layout_marginLeft="16dp" 
      android:layout_marginRight="16dp" 
      android:orientation="vertical"> 

<ScrollView 
    android:id="@+id/inner_scroll_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_above="@+id/detail_note_date_text" 
    android:fillViewport="true" 
    android:> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

      <EditText 
       android:id="@+id/detail_title_edit_text" 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight="8" 
       android:backgroundTint="@android:color/background_light" 
       android:hint="@string/title_hint" 
       android:inputType="textShortMessage" 
       android:textSize="24dp" 
       /> 

      <EditText 
       android:id="@+id/detail_note_edit_text" 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight="48" 
       android:gravity="top" 
       android:hint="@string/note_hint" 
       android:textSize="16dp" 
       /> 

      <RadioGroup 
       android:id="@+id/reminder_radio_group" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 

       <RadioButton 
        android:id="@+id/radio_no_set_reminder" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/radio_button_no_set_reminder"/> 

       <RadioButton 
        android:id="@+id/radio_set_reminder" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/radio_button_set_reminder"/> 
      </RadioGroup> 
     </LinearLayout> 
     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"/> 
    </LinearLayout> 
</ScrollView> 

<TextView 
    android:id="@+id/detail_note_date_text" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_centerInParent="true" 
    android:layout_gravity="center" 
    android:layout_weight="2" 
    tools:text="@string/demo_date"/> 

+0

當你運行應用程序,它是如何看?你能在這裏發送截圖嗎? –

回答

0

嘗試如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginBottom="8dp" 
     android:layout_marginLeft="16dp" 
     android:layout_marginRight="16dp"> 

<ScrollView 
android:id="@+id/inner_scroll_view" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:layout_above="@+id/detail_note_date_text" 
> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

     <EditText 
      android:id="@+id/detail_title_edit_text" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:backgroundTint="@android:color/background_light" 
      android:hint="@string/title_hint" 
      android:inputType="textShortMessage" 
      android:textSize="24dp" 
      /> 

     <EditText 
      android:id="@+id/detail_note_edit_text" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="top" 
      android:hint="@string/note_hint" 
      android:textSize="16dp" 
      /> 

     <RadioGroup 
      android:id="@+id/reminder_radio_group" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <RadioButton 
       android:id="@+id/radio_no_set_reminder" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/radio_button_no_set_reminder"/> 

      <RadioButton 
       android:id="@+id/radio_set_reminder" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/radio_button_set_reminder"/> 
     </RadioGroup> 
    </LinearLayout> 
    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 

</ScrollView> 

<TextView 
android:id="@+id/detail_note_date_text" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_alignParentBottom="true" 
android:layout_centerHorizontal="true" 
android:text="@string/demo_date"/> 

</RelativeLayout> 
+0

我剛剛編輯了您的代碼。請嘗試正確地學習第一個版式設計,並且只有當您的內容足夠大才能從屏幕中移出時,視圖纔會滾動。 – Drv

+0

它的工作方式,但我想editText字段佔據屏幕?有什麼辦法可以幫助我嗎? –

+0

意思是當edittext的鍵盤打開的時候,你想滾動上面的整個佈局嗎? – Drv