windowSoftInputMode设置为stateHidden | adjustResize在Android中不起作用

时间:2013-07-05 14:00:41

标签: android view android-softkeyboard

我有以下布局

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:background="@drawable/background_grey"
android:fillViewport="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical" >

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <RelativeLayout
        android:id="@+id/logo_layout"
        android:layout_width="fill_parent"
        android:layout_height="@dimen/layout_height"
        android:layout_alignParentTop="true"
        android:background="@drawable/logo_container" >

        <!-- some layout components-->
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/logo_layout"
        android:layout_margin="@dimen/default_margin" >

                    <!-- some layout components-->

        <RelativeLayout
            android:id="@+id/activation_code_entry_layout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/activation_body_second_paragraph"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="20dp"
            android:background="@drawable/enter_passcode_background"
            android:gravity="center_vertical" >

                        <!-- some layout components-->

            <EditText
                android:id="@+id/activationCode"
                style="@style/FormField"
                android:layout_alignParentRight="true"
                android:layout_marginRight="@dimen/side_margin"
                android:hint="@string/activation_enter_code"
                android:inputType="number"
                android:maxLength="10"/>

                        <!-- some layout components-->
        </RelativeLayout>

                    <!-- some layout components-->
    </RelativeLayout>
</RelativeLayout>

</ScrollView>

并在Application Manifest文件中,我将活动设置为

<activity
        android:name=".activities.MyActivity"
        android:enabled="true"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:theme="@android:style/Theme.NoTitleBar"
        android:windowSoftInputMode="stateHidden|adjustResize" >
    </activity>

但是当软键盘出现时,视图不会向上滚动。

2 个答案:

答案 0 :(得分:5)

如果您使用没有标题栏的主题,则不会调整大小。 也许这个问题可以帮到你: Android How to adjust layout in Full Screen Mode when softkeyboard is visible

答案 1 :(得分:2)

我设法解决了我的问题。在这里。

我按以下方式修改了主滚动视图的第一个子项

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom" >

即。我添加了

    android:layout_gravity="bottom"

这使得布局总是显示底部,因为重力是底部。

我希望这有助于其他人

干杯

相关问题