在 EditText 中放置文本时滚动视图
如何在 EditText 中输入内容时使整个视图可滚动? 我正在执行注册屏幕,但我被困在这里。
我有一个滚动视图和相对布局,其中有编辑文本和按钮。
这是我的代码:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:fillViewport="true">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp">
<ImageView
android:id="@+id/logo"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:src="@drawable/logo" />
<EditText
android:id="@+id/login_input"
android:layout_width="260dp"
android:layout_height="35dp"
android:layout_centerHorizontal="true"
android:layout_below="@id/logo"
android:background="@drawable/no_corner_edit_text"
android:inputType="textEmailAddress"
android:hint="@string/email_address"
android:paddingLeft="10dp">
<requestFocus />
</EditText>
<EditText
android:id="@+id/password_input"
android:layout_width="260dp"
android:layout_height="35dp"
android:layout_centerHorizontal="true"
android:layout_below="@id/login_input"
android:layout_marginTop="14dp"
android:background="@drawable/no_corner_edit_text"
android:inputType="textPassword"
android:hint="Password"
android:paddingLeft="10dp"/>
<Button
android:text="Login"
android:id="@+id/login_button"
android:layout_height="40dp"
android:layout_width="200dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:textColor="#ffffff"
android:background="@drawable/blue_button1"
android:layout_below="@id/password_input"/>
<Button
android:text="Create Account"
android:id="@+id/create_account_button"
android:layout_height="40dp"
android:layout_width="200dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:layout_marginBottom="5dp"
android:textColor="#000000"
android:background="@drawable/grey_button1"
android:layout_below="@id/login_button"/>
</RelativeLayout>
</ScrollView>
ScrollView 根本不起作用。
How to make the whole view scrollable during typing in EditText?
I am doing the Registration screen and I get stuck here.
I've got a scrollview and relativelayout inside where are edittext's and buttons.
This is my code:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:fillViewport="true">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp">
<ImageView
android:id="@+id/logo"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:src="@drawable/logo" />
<EditText
android:id="@+id/login_input"
android:layout_width="260dp"
android:layout_height="35dp"
android:layout_centerHorizontal="true"
android:layout_below="@id/logo"
android:background="@drawable/no_corner_edit_text"
android:inputType="textEmailAddress"
android:hint="@string/email_address"
android:paddingLeft="10dp">
<requestFocus />
</EditText>
<EditText
android:id="@+id/password_input"
android:layout_width="260dp"
android:layout_height="35dp"
android:layout_centerHorizontal="true"
android:layout_below="@id/login_input"
android:layout_marginTop="14dp"
android:background="@drawable/no_corner_edit_text"
android:inputType="textPassword"
android:hint="Password"
android:paddingLeft="10dp"/>
<Button
android:text="Login"
android:id="@+id/login_button"
android:layout_height="40dp"
android:layout_width="200dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:textColor="#ffffff"
android:background="@drawable/blue_button1"
android:layout_below="@id/password_input"/>
<Button
android:text="Create Account"
android:id="@+id/create_account_button"
android:layout_height="40dp"
android:layout_width="200dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:layout_marginBottom="5dp"
android:textColor="#000000"
android:background="@drawable/grey_button1"
android:layout_below="@id/login_button"/>
</RelativeLayout>
</ScrollView>
ScrollView is not working at all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论