Mr Robot
Mr Robot

Reputation: 1747

Android EditText typed text not showing when keyboard appears in Fragment

Im using an EditText in Fragment with a textView,Button and ImageView.

My Problem is :

I cant see what im typing when keyboard appears.

My XML code is :

 <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>

ScreenShots : when Keyboard appears: I cant see what im typing enter image description here

after typing and keyboard disappears only then i can see what im typed: enter image description here

Please someone help me to solve me my problem

Upvotes: 3

Views: 2473

Answers (3)

Aanal Shah
Aanal Shah

Reputation: 2106

Though it's very late to reply to this post. I faced the same issue and solved it with

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

I dynamically set this flag based on the screen requirement.

Upvotes: 4

dara
dara

Reputation: 763

<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"
tools:context="ictnews.iutlab.uz.ictnews.fragments.CommentFragment">


<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/swipe_fragment_comment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/linerlayout"
    >

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_fragment_comment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="top" />
</android.support.v4.widget.SwipeRefreshLayout>

<LinearLayout
    android:id="@+id/linerlayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:orientation="horizontal"
    android:padding="@dimen/space_margin"
    android:weightSum="1">

    <EditText
        android:id="@+id/edit_fragment_comment"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".9"
        android:hint="@string/comment_hint"
        android:inputType="text"
        android:theme="@style/EditTextComment" />

    <ImageView
        android:id="@+id/fab_comment_fragment"
        android:layout_width="0dp"
        android:layout_height="30dp"
        android:layout_weight=".1"
        android:background="?attr/selectableItemBackground"
        android:clickable="true"
        android:src="@drawable/ic_action_send" />

</LinearLayout>

Upvotes: 1

dara
dara

Reputation: 763

Use RelativeLayout rather than FrameLayout and You don`t need parent viewgroup for ScrollView I think it should work her we go

<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>

Upvotes: 1

Related Questions