2012-04-04 4 views
5

Я пытаюсь прокрутить мой относительный макет. Я добавил прокрутку в качестве родителя, но когда я наклоняю телефон или эмулятор к горизонтали, он не прокручивается.Использование RelativeLayout внутри ScrollView не работает при прокрутке

Я пробовал несколько разных решений, но ни один из них, похоже, не работает. Некоторые из них включают: No scrolling in scrollview, ScrollView not Working - Relative Layout и RelativeLayout with scrollview not scrolling

Код следующее:

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

Спасибо!

ответ

3

RelativeLayout Установлен в fill_parent. Если он имеет тот же размер, что и его родительский ScrollView, прокручивать нечего. Сделайте это wrap_content вместо этого и правильно разместите своих детей, чтобы указать высоту.

+0

я сделал это. Я изменил relativelayout от заполнения родителя до wrap_content. Он бросает все влево и не прокручивает. Я изменил scrollview, чтобы обернуть содержимое, и я не могу перестроить поля relativeLayout – Dan

0

android:fillViewport="true"

добавить эту строку в качестве атрибута просмотра прокрутки :)

Смежные вопросы