我已经查看了各种答案,但是在可见键盘时无法向上移动视图。我在recyclerview中有一个编辑文本,其焦点键盘可见。我希望当键盘可见时将tv_character_limit文本上移。我需要将字符限制文本显示为带有z-index的高位。我已将windowSoftInputMode设置为该活动的adjustResize,并为视图分页器中的片段添加了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>
答案 0 :(得分:0)
使用
android:windowSoftInputMode="adjustPan"
清单文件中的您的活动。 例如:
<activity
android:name=".View.Activity.yourActivity"
android:windowSoftInputMode="adjustPan"/>
答案 1 :(得分:0)
使用RelativeLayout代替FrameLayout,并在EditText获得焦点时,只需调用类似于layout_above的RelativeLayout类方法来更改TextView的位置。