2012-04-04 19 views
5

Ich versuche, mein relatives Layout zum Scrollen zu bekommen. Ich habe die Bildlaufansicht als Eltern hinzugefügt, aber wenn ich das Telefon oder den Emulator in die horizontale Position kippe, scrollt es nicht.Verwenden RelativeLayout innerhalb ScrollView nicht in Scrollen

Ich habe ein paar verschiedene Lösungen versucht, aber keine von ihnen scheint zu funktionieren. Einige sind: No scrolling in scrollview, ScrollView not Working - Relative Layout und RelativeLayout with scrollview not scrolling

Der Code ist der folgende:

<?xml version="1.0" encoding="utf-8"?> 

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/ScrollView01" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:fillViewport="true" 
    android:scrollbars="none"> 
<RelativeLayout 

    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical"> 

     <Button 
      android:layout_width="200dp" 
      android:id="@+id/register_button" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="true" 
      android:text="Register" /> 

     <EditText 
      android:id="@+id/email2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/register_button" 
      android:layout_alignLeft="@+id/register_button" 
      android:layout_alignRight="@+id/register_button" 
      android:hint="Re-Enter Email" 
      android:inputType="textEmailAddress" /> 

     <EditText 
      android:id="@+id/email1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/email2" 
      android:layout_alignLeft="@+id/email2" 
      android:layout_alignRight="@+id/email2" 
      android:hint="Email" 
      android:inputType="textEmailAddress" /> 

     <EditText 
      android:id="@+id/password2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/email1" 
      android:layout_alignLeft="@+id/email1" 
      android:layout_alignRight="@+id/email1" 
      android:hint="Repeat Password" 
      android:inputType="textPassword" /> 

     <EditText 
      android:id="@+id/password1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/password2" 
      android:layout_alignLeft="@+id/password2" 
      android:layout_alignRight="@+id/password2" 
      android:hint="Password" 
      android:inputType="textPassword" /> 

     <EditText 
      android:id="@+id/lastName" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/password1" 
      android:layout_alignLeft="@+id/password1" 
      android:layout_alignRight="@+id/password1" 
      android:hint="Last Name" 
      android:imeOptions="actionNext" 
      android:inputType="textPersonName" /> 

     <EditText 
      android:id="@+id/firstName" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/lastName" 
      android:layout_alignLeft="@+id/lastName" 
      android:layout_alignRight="@+id/lastName" 
      android:hint="First Name" 
      android:imeOptions="actionNext" 
      android:inputType="textPersonName" /> 

     <EditText 
      android:id="@+id/userName" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/firstName" 
      android:layout_alignLeft="@+id/firstName" 
      android:layout_alignRight="@+id/firstName" 
      android:hint="Username" 
      android:imeOptions="actionNext" 
      android:inputType="textPersonName" /> 




</RelativeLayout> 
</ScrollView> 

Dank!

Antwort

3

Ihre RelativeLayout ist auf fill_parent eingestellt. Wenn es die gleiche Größe wie sein ScrollView Eltern hat, gibt es nichts zu scrollen. Mache es stattdessen wrap_content und ordne seine Kinder so an, dass sie eine Höhe implizieren.

+0

ich das tat. Ich habe das relative Layout von fill parent in wrap_content geändert. Es wirft alles nach links und kein Scrollen. Ich habe scrollview geändert, um den Inhalt zu umbrechen, und ich kann die Felder von relativeLayout nicht neu ausrichten – Dan

0

android:fillViewport="true"

diese Zeile als Scroll-Ansicht Attribut hinzufügen :)

Verwandte Themen