Установить текстовый курсор над мягкой клавиатурой - PullRequest
0 голосов
/ 13 мая 2018

У меня есть несколько многострочных элементов управления EditText в ScrollView. Когда я нажимаю на любой из элементов управления EditText, появляется программная клавиатура,

но EditText и его позиция курсора появляются за клавиатурой. Мне нужно вручную прокрутить вид сверху.

Я попытался прокрутить scrollView к низу при нажатии EditText, но это не сработает, так как клавиатура появляется после нажатия EditText onClick, а раскладка изменяется по мере появления клавиатуры.

Есть ли способ исправить эту проблему? В приведенном ниже коде кнопка camera всегда отображается над клавиатурой.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    android:id="@+id/crlayout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_height="match_parent"
    android:layout_width="match_parent">
<ScrollView
        android:id="@+id/scrollview"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:layout_alignParentTop="true">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
        <ImageView
            android:id="@+id/boxImage"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            />
        <EditText
            android:id="@+id/new_box_title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:hint="Title"
            android:inputType="textPersonName" />

        <EditText
            android:id="@+id/new_box_descri"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Description"
            android:gravity="top"
            android:inputType="textCapSentences|textMultiLine"
            android:lines="5"
            android:windowSoftInputMode="stateAlwaysVisible" />

</LinearLayout>
    </ScrollView>
    <LinearLayout
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:layout_alignParentBottom="true"
        android:orientation="horizontal"
        android:background="@android:color/white"
        >
        <ImageButton
            android:id="@+id/cameraButton"
            android:layout_width="wrap_content"
            android:layout_height="50dp"
            android:layout_weight="1"
            android:contentDescription="Open Camera"
            app:srcCompat="@drawable/ic_box_camera_icon"
            android:background="?attr/selectableItemBackgroundBorderless"
            />
    </LinearLayout>
</RelativeLayout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...