当键盘出现在片段中时,Android EditText键入的文本不显示

当键盘出现在片段中时,Android EditText键入的文本不显示,android,android-fragments,android-edittext,Android,Android Fragments,Android Edittext,我使用一个片段中的EditText和一个textView、按钮和ImageView 我的问题是: 当键盘出现时,我看不到我在输入什么 我的XML代码是: <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent

我使用一个片段中的EditText和一个textView、按钮和ImageView

我的问题是:

当键盘出现时,我看不到我在输入什么

我的XML代码是:

 <FrameLayout 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="@android:color/background_light"
        android:clickable="true">

        <!-- TODO: Update blank fragment layout -->

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="5dp">

            <ScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent">

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

                    <ImageView
                        android:layout_width="match_parent"
                        android:layout_height="190dp"
                        android:background="@drawable/header" />

                    <TextView
                        android:id="@+id/head"
                        style="@style/Base.TextAppearance.AppCompat.Large"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="sub heading" />

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

                        <EditText
                            android:id="@+id/request_et"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:hint="Enter your Name and Address here"
                            android:maxLines="10"
                            android:minLines="6" />
                    </android.support.design.widget.TextInputLayout>
                </LinearLayout>

            </ScrollView>

            <Button
                android:id="@+id/request_btn"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:background="@color/colorPrimary"
                android:text="Button"
                android:textColor="@android:color/background_light" />
        </RelativeLayout>
    </FrameLayout>

输入和键盘消失后,我才能看到我输入的内容:


请有人帮我解决我的问题

使用RelativeLayout而不是FrameLayout,你不需要ScrollView的父视图组,我认为它应该可以工作,我们走吧

<RelativeLayout 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="@android:color/background_light"
    android:clickable="true">

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="5dp">

                <ImageView
                    android:id="@+id/img"
                    android:layout_width="match_parent"
                    android:layout_height="190dp"
                    android:background="@drawable/header" />

                <TextView
                    android:id="@+id/head"
                    style="@style/Base.TextAppearance.AppCompat.Large"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="sub heading"
                    android:layout_below="@+id/img" />

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

                    <EditText
                        android:id="@+id/request_et"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="Enter your Name and Address here"
                        android:maxLines="10"
                        android:minLines="6" />
                </android.support.design.widget.TextInputLayout>
            </RelativeLayout>

        </ScrollView>

        <Button
            android:id="@+id/request_btn"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:background="@color/colorPrimary"
            android:text="Button"
            android:textColor="@android:color/background_light"
            android:layout_gravity="bottom"/>

</RelativeLayout>



虽然现在回复这篇文章已经很晚了。我也面对同样的问题,用同样的方法解决了它

window.setFlags(
    WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
    WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
)

我根据屏幕要求动态设置此标志。

哇,这是绝密机密应用程序吗?@LeonardoFerrari:这是问题吗?您的按钮需要限制。“滚动视图下方的布局”并将已添加的底部与顶部对齐。仍然相同。无更改我认为您必须从底部按钮删除并运行它,如果它起作用,则您必须将按钮替换到另一个位置,但我需要将按钮与布局的引导框对齐。当我想在我的应用程序中实现评论功能时,我也有同样的问题,我会给您我的代码。谢谢,请尽快更新您的答案
window.setFlags(
    WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
    WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
)