android - Android当键盘打开底部EditText不显示
问题描述
我将 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>
我的服装行是这样的:
<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>
推荐阅读
- c# - StreamReader 未将 MediaStream 转换为字符串
- error-handling - 使用 Xcode12.2 在 iOS11 上安装/更新 pod
- python-3.x - 使用opencv检测护照图像中的文本
- c# - EF Core:我可以在我的实体中将可为空的 SQL 类型映射到不可为空的值类型吗?
- django - 如何防止用户在 django 中提交后返回表单(所有表单登录、编辑帖子等)?
- python - 超声波范围传感器 (HC-SR04) 在 Raspberry Pi 上给出不一致的读数
- javascript - 反应 - 从状态数据计算总数
- pandas - numpy 数组到数据框,反之亦然
- cocoa - Cocoa:当窗口最小化以停靠时未调用 NSViewController.viewWillAppear() 和 viewDidAppear()
- r - 用形状和颜色更改ggplot中的图例标题