小编Yul*_*lia的帖子

如何强制软键盘不隐藏编辑文本下的文本视图/计数器?

问题是android键盘在打开时将textview隐藏在edittext下(不是edittext本身!)

这是我的布局示例:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    tools:context=".MainActivity">


    <android.support.v4.widget.NestedScrollView
        android:id="@+id/nestedScrollView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/big_image"
                android:layout_width="200dp"
                android:layout_height="600dp"
                android:layout_centerHorizontal="true"
                android:background="@color/colorPrimary"
                android:src="@drawable/ic_launcher_foreground"/>


            <android.support.design.widget.TextInputLayout
                android:id="@+id/comment_input_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/big_image">

                <EditText
                    android:id="@+id/comment_edittext_view"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="your comment"
                    android:imeOptions="actionDone"
                    android:maxLength="250"/>
            </android.support.design.widget.TextInputLayout>

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/comment_input_layout"
                android:text="0/250"/>
        </RelativeLayout>

    </android.support.v4.widget.NestedScrollView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

下面的图片可以清楚地说明:

没有键盘的屏幕

实际行为

预期行为

我在stackoverflow上发现了几个类似的问题,没有一个有解决方案:(请帮我解决这个问题!请确保,我使用了所有考虑android:windowSoftInputMode="adjustPan"android:windowSoftInputMode="adjustResize"android:focusableInTouchMode="true" 或的建议android:fitsSystemWindows="true" 或将这个textview与edittext布局分开,将framelayout作为根,

但问题有点复杂。

另一个重要的事情是,edittext 下面的这个文本应该

  • 当文本在另一行上时保持在键盘上方

  • 当 edittext 向上滚动时消失(因为它是 edittext 的一部分)。

android android-softkeyboard android-edittext

7
推荐指数
1
解决办法
700
查看次数