android - 无法使用键盘 Android 向上移动视图
问题描述
我已经经历了各种答案,但是当键盘可见时无法向上移动我的视图。我在 recyclerview 中有一个编辑文本,其焦点键盘可见。我希望 tv_character_limit 文本在键盘可见时向上移动。我需要用 z-index 显示字符限制文本。我已将 windowSoftInputMode 设置为针对活动和视图寻呼机中的片段进行调整大小,我已添加了 java 代码:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
谢谢你的帮助。下面是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rel_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@color/pink">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar_post" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_status"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" />
<TextView
android:id="@+id/tv_character_limit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_marginRight="10dp"
android:layout_marginBottom="30dp"
android:text="@string/character_limit"
android:textColor="@color/tap_to_type"
android:textSize="15dp" />
</FrameLayout>
解决方案
使用RelativeLayout 代替FrameLayout,当EditText 获得焦点时,只需调用类似于layout_above 的RelativeLayout 类方法来更改TextView 的位置。
推荐阅读
- javascript - 滚动事件关闭菜单后,导航下拉切换不显示菜单
- c++ - 画椭圆延迟,再画一个
- python - 如何将在脚本编辑器中制作的 Apple 脚本与 PyCharm 中的 Python 项目结合起来?
- r - 删除仅在 R 中的向量列表中出现一次的元素
- c# - 您如何知道一个集合将充当 IEnumerable 还是 IQueryable?
- firebase - 如何将电话身份验证添加到现有用户帐户
- python - 非字符键的 UTF-8 编码
- javascript - 我正在尝试遍历一个数组并找到在属性中说过关键字的每个对象
- bash - 获取在特定时间范围内更改的所有文件
- c++ - 使用指数将十进制转换为二进制