2016-07-04 87 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