Search code examples
androidandroid-edittextandroid-softkeyboard

Soft keyboard covers TextView below EditText


I placed a TextView below an EditText to display the latter's character count. This is how it looks like when the EditText is not in focus.

enter image description here

When the EditText is in focus:

enter image description here

As you can see, "7/500" has been covered by the TextView.

The XML for my activity:

<ScrollView
    android:id="@+id/list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="20dp"
    android:paddingTop="10dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:focusable="true"
        android:focusableInTouchMode="true">

        <ImageView
            android:id="@+id/display_photo"
            android:layout_width="match_parent"
            android:layout_height="250dp"
            android:layout_gravity="center_horizontal"
            android:adjustViewBounds="true"/>

        <android.support.design.widget.TextInputLayout
            android:id="@+id/caption_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="7dp">

            <android.support.design.widget.TextInputEditText
                android:id="@+id/et_start_photo_story_title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:adjustViewBounds="true"
                android:gravity="bottom"
                android:maxLength="500"
                android:paddingBottom="15dp"
                android:privateImeOptions="nm"
                android:textColor="@color/black" />
        </android.support.design.widget.TextInputLayout>

        <TextView
            android:id="@+id/tv_character_count"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:textColor="@color/grey700"
            android:textSize="14sp" />
    </LinearLayout>
</ScrollView>

I have this line inside my manifest android:windowSoftInputMode="adjustPan". I have tried changing the height of the ImageView, but the character count remains hidden when the EditText is in focus.


Solution

  • Instead of setting as

    android:windowSoftInputMode="adjustPan"

    try setting as

    android:windowSoftInputMode="adjustResize"

    which will make your view scrollable when edittext is focused.