android - Android - 出现软键盘时 VideoView 隐藏的图像
问题描述
我知道这是一个常见问题,但我无法弄清楚。我有这个布局:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/greyB2"
xmlns:app="http://schemas.android.com/apk/res-auto">
<VideoView
android:id="@+id/video_intro"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ImageView
android:id="@+id/back_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_back"
android:layout_marginTop="30dp"
android:layout_marginStart="16dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/email_field"
android:layout_width="320dp"
android:layout_height="wrap_content"
android:background="@drawable/white_borders_et"
android:fontFamily="@font/exo_bold"
android:hint="@string/sign_in_email"
android:inputType="textEmailAddress"
android:textColor="@color/white"
android:textColorHint="@color/white"
android:textAlignment="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/access_btn"/>
<Button
android:id="@+id/access_btn"
style="@style/ButtonRed"
android:layout_width="150dp"
android:layout_height="47dp"
android:text="@string/intro_access"
android:textAllCaps="false"
android:textSize="20sp"
android:layout_marginTop="12dp"
android:layout_marginBottom="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
当点击 EditText 后出现键盘时,back_icon ImageView 被向上推。
我在清单中尝试了
android:windowSoftInputMode="adjustPan"
和其他参数,但没有任何效果。提前致谢
编辑:对不起,我忽略了这个问题,但后来我意识到这是一切的原因:我有一个全屏 VideoView(更新了 xml 代码)。当键盘消失时,back_icon 就像被 VideoView “混淆”一样(图标不再可见但可点击,点击时会触发点击监听器。)。即使我给 back_icon 提升,问题仍然存在。
解决方案
解决方案很简单:
在活动标签中添加android:windowSoftInputMode="stateVisible|adjustResize"
到清单文件中。如下:
<activity android:name=".YourActivity"
android:windowSoftInputMode="stateVisible|adjustResize">
//............
</activity>
推荐阅读
- android - 具有多个活动的 JetPack 导航组件?
- gradle - 添加约束布局后无法同步项目
- c# - 使用多个筛选器的 Azure 搜索
- laravel - 缺少路由所需的参数:仪表板 URI:laravel 中的仪表板/{id}
- visual-studio-code - vscode live share:在本地运行共享代码
- inheritance - Kotlin 接口实现打破了 `equals` 覆盖
- java - 在eclipse中运行TestNG程序时出现错误:发生JNI错误,请检查您的安装并重试
- python - 从文本文件中提取数据并将其转换为 df
- angular - 服务全部完成时函数中的返回值
- sql-server - 使用带有全文搜索支持的 docker 安装 MSSQL 服务器 express