簡體   English   中英

當鍵盤打開底部EditText不顯示時的Android

[英]Android When Keyboard Open Bottom EditText Not Showing

我在Costum行中使用RecyclerView。 Costum行具有線性布局(水平),並且具有兩個TextView,一個EditText,行數為50。所以我的問題是,當鍵盤打開底部顯示的EditText現在顯示時,我只能使用鍵盤的Enter鍵顯示EditText。 我想在鍵盤打開時調整屏幕大小或類似的內容。 我試過了,但是沒有用。 android:windowSoftInputMode="adjustResize"

我的活動:

<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>

我的Costum Row這樣:

<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>

只需將android:fitsSystemWindows="true"從您的活動添加到根視圖中,如下例所示。

<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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM