Dan*_*Dan 5 android scrollview relativelayout android-layout
我正试图让我的相对布局滚动.我将滚动视图添加为父级,但是当我将手机或模拟器倾斜到水平时,它不会滚动.
我尝试了几种不同的解决方案,但似乎都没有.一些包括: 滚动视图中无滚动,ScrollView无法工作 - 相对布局,而滚动视图不滚动的RelativeLayout
代码如下:
<?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>
Run Code Online (Sandbox Code Playgroud)
谢谢!
您的RelativeLayout设置为fill_parent. 如果它的大小与ScrollView其父级相同,则没有任何内容可以滚动。相反wrap_content,并正确布局其子项以暗示高度。
| 归档时间: |
|
| 查看次数: |
3783 次 |
| 最近记录: |