Мягкая клавиатура приходит поверх EditText - PullRequest
2 голосов
/ 01 июня 2011

Я использую Eclipse ADT для разработки приложения для Android.Когда фокус переходит к одному из текстов редактирования (в нижней части страницы), клавиатура закрывает текст редактирования, поэтому, когда я набираю текст, я не вижу, что вводится. Какие у меня варианты?

Структура индекса активности

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:background="#a8e8f0" android:orientation="vertical" android:id="@+id/layout">
    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:orientation="vertical" android:background="@drawable/welcome_background">
        <include layout="@layout/top"></include>
        <RelativeLayout android:layout_height="wrap_content"
            android:layout_width="fill_parent" android:gravity="center">
            <LinearLayout android:layout_width="270dp"
                android:orientation="vertical" android:layout_height="wrap_content"
                android:id="@+id/body">
                <ImageView android:layout_width="wrap_content" android:src="@drawable/welcome_title" android:layout_height="wrap_content" android:id="@+id/title" style="@style/Theme.Connector.ImageElement"></ImageView>
                <TextView android:text="@string/welcome_text" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/txt_welcome" style="@style/Theme.Connector.FormText"></TextView>
                <Spinner android:layout_width="fill_parent"
                    android:layout_height="wrap_content" style="@style/Theme.Connector.WelcomeSpinner"
                    android:layout_weight="1" android:id="@+id/spinner_isp" />
                <EditText android:layout_height="wrap_content" android:singleLine="true"
                    style="@style/Theme.Connector.WelcomeInput" android:hint="@string/txt_user"
                    android:layout_width="fill_parent" android:id="@+id/edit_user"></EditText>
                <EditText android:layout_alignParentLeft="true"  android:singleLine="true"
                    android:layout_height="wrap_content" style="@style/Theme.Connector.WelcomeInput"
                    android:hint="@string/txt_password" android:layout_width="fill_parent"
                    android:password="true" android:id="@+id/edit_password"/>
                <LinearLayout android:layout_width="fill_parent"
                    android:orientation="horizontal" android:layout_height="fill_parent"
                    android:id="@+id/frm_action">
                    <Button style="@style/Theme.Connector.Button"
                        android:layout_height="wrap_content" android:layout_width="100dp"
                        android:text="@string/btn_cancel" android:layout_weight="1"
                        android:id="@+id/btn_cancel" />
                    <Button android:text="@string/btn_continue"
                        android:layout_height="wrap_content" android:layout_width="100dp"
                        style="@style/Theme.Connector.ButtonContinue"
                        android:layout_weight="1" android:id="@+id/btn_continue"></Button>
                </LinearLayout>
            </LinearLayout>
        </RelativeLayout>
    </LinearLayout>
</LinearLayout>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="vex.connector" android:versionCode="1" android:versionName="1.0">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application android:icon="@drawable/icon" android:label="@string/app_name"
        android:theme="@style/Theme.Connector">

        <activity android:name=".IndexActivity" android:label="@string/app_name"
            android:screenOrientation="portrait" android:windowSoftInputMode="stateVisible|adjustPan">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <receiver android:name=".WiFiBroadcastReceiver">
            <intent-filter>
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
            </intent-filter>
        </receiver>

    </application>
</manifest>

Клавиатура

keyboard

Ответы [ 3 ]

9 голосов
/ 01 июня 2011

Оберните ваш внешний LinerLayout в ScrollView, например,

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    ...

    <!-- Your current layout here -->

</ScrollView>

Это должно позволить прокрутить макет, чтобы увидеть нижний EditText

1 голос
/ 22 апреля 2017

Если ни один из этих ответов не помогает убедиться, что ваш стиль не устанавливает этот атрибут:

<item name="android:windowTranslucentStatus">true</item>

Если это так, переопределите стиль для вашей деятельности.

1 голос
/ 18 июля 2012

У меня была точно такая же проблема, и я нашел, что подход Таркешвара был лучше.

Что произойдет, если вы установите android: windowSoftInputMode = "AdjustResize" вместо AdjustPan, который вы используете в настоящее время?Кроме того, вы используете полноэкранный стиль (Android: WindowFullscreen)?Только сегодня у меня была похожая проблема наложения программных клавиш.Исправлено использование AdjustResize и избавление от полноэкранного стиля.

tarkeshwar

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...