怎么会出现键盘的时候做出一个Android视图滚动?视图、键盘、时候、Android

2023-09-06 04:39:25 作者:只为博伱倾城一笑

我有一些领域的视图(姓名,电子邮件,密码,注册按钮):

I have a view with some fields (name, email, password, register button) :

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ViewFlipper
        android:id="@+id/viewflipper"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        //Layouts

    </ViewFlipper>

</ScrollView>

当我专注一个EditText字段,键盘出现,并覆盖在视图下方区域。所以,我看不到他们,当键盘是present。我想知道如何使视图滚动,这样我可以看到下方区域。 ,另外,如何自动使视图滚动,使重点领域可见。

When I focus an edittext field, the keyboard appears and is overlaying the lower fields on the view. So I can't see them when the keyboard is present. I would like to know how to make the view scrollable so that I can see the lower fields. And additionally, how to make the view scroll automatically to make the focused field visible.

推荐答案

您需要包括安卓windowSoftInputMode =adjustResize属性您在AndroidManifest.xml活动文件 - 然后机器人会自动做调整大小为您:

You need to include android:windowSoftInputMode="adjustResize" attribute for your activity in the AndroidManifest.xml file - and then Android should do the resizing for you automatically:

<activity android:name="..."
          ...
          android:windowSoftInputMode="adjustResize">
    ...
/>