简体   繁体   中英

Android When Keyboard Open Bottom EditText Not Showing

I use RecyclerView with costum row. Costum row has Linear Layout (horizontal) and it has two TextView, one EditText and the row count is 50. So my problem is when keyboard open my bottom EditText now showing, I can just show the EditText with keyboard 'Enter' button. I want to when keyboard open the screen resize or something like that. I tried that but it's not working. android:windowSoftInputMode="adjustResize"

My Activity:

<RelativeLayout
android:id="@+id/playGameRelative"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FDF2DF"
tools:context=".PlayGameActivity">

<RelativeLayout
    android:id="@+id/playGameInfoTop"
    android:layout_width="match_parent"
    android:layout_height="45dp"
    android:background="#D0C7B7">

    <TextView
        android:id="@+id/playGameTxtGameTimer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="20sp"
        android:textStyle="bold"
        android:layout_centerVertical="true"
        android:layout_alignParentEnd="true"
        android:layout_marginEnd="10dp"/>

</RelativeLayout>

<android.support.v7.widget.RecyclerView
    android:id="@+id/playGameRecycle"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/playGameInfoTop"
    android:layout_above="@+id/playGameBtnShowResult"/>

<Button.../>
</RelativeLayout>

And my Costum Row like that:

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="4dp"
android:layout_marginBottom="4dp">

<TextView
    android:id="@+id/rowGameNumber"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="0.1"
    android:textAlignment="center"
    android:gravity="center"
    android:textSize="18sp"
    android:textStyle="bold"
    android:textColor="@color/colorLogoBlue"/>

<EditText
    android:id="@+id/rowGameEditText"
    android:text="sokak lambası"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="0.45"
    android:paddingStart="14dp"
    android:inputType="text"
    android:textColor="@color/colorButtonRegister"
    android:background="@drawable/background_edittext_game"
    android:maxLines="1"
    android:enabled="false"/>

<TextView
    android:id="@+id/rowGameCorrectAnswer"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="0.45"
    android:layout_marginStart="14dp"
    android:textStyle="bold"
    android:textSize="18sp"
    android:textAlignment="center"
    android:background="@drawable/background_text_game_correct"
    android:visibility="invisible"/>

</LinearLayout>

Just add the android:fitsSystemWindows="true" to the root view from your activity like the example below.

<RelativeLayout
    android:id="@+id/playGameRelative"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FDF2DF"
    android:fitsSystemWindows="true"
    tools:context=".PlayGameActivity">

    <!-- All your code here -->

</RelativeLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM