Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EditText inside a fragment is Hidden when soft keyboard opens

Tags:

android

My Activity contains two fragments , at the bottom a control bar and above it this layout with two EditText:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/invested_grey_color" >

<RelativeLayout
    android:id="@+id/relativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginTop="5dp"
    android:background="@color/transperent_black" >

    <com.threefishmedia.sportzone.views.TextViewCustomFont
        android:id="@+id/choose_a_set_LeagueName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/view_tournament_rules"
        android:textColor="@color/white"
        android:textSize="20sp" />

    <ImageView
        android:id="@+id/choose_a_set_view_tournamnet_rules_iv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="10dp"
        android:layout_toLeftOf="@+id/choose_a_set_LeagueName"
        android:clickable="true"
        android:src="@drawable/question" />
</RelativeLayout>

<RelativeLayout
    android:id="@+id/Choose_a_set_rl"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/relativeLayout1"
    android:layout_marginTop="15dp"
    android:background="@color/transperent_sportzone_green" >

    <com.threefishmedia.sportzone.views.TextViewCustomFont
        android:id="@+id/choose_a_set_stage_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:layout_marginBottom="20dp"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="20dp"
        android:text="@string/choose_a_set"
        android:textColor="@color/sportzone_green"
        android:textSize="35sp" />

    <ImageView
        android:id="@+id/choose_a_set_vi_sign_iv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_marginRight="20dp"
        android:src="@drawable/ic_launcher" />
</RelativeLayout>

<RelativeLayout
    android:id="@+id/make_it_your_own"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/Choose_a_set_rl"
    android:layout_marginTop="1dp"
    android:background="@color/transperent_sportzone_green" >

    <com.threefishmedia.sportzone.views.TextViewCustomFont
        android:id="@+id/make_it_your_own_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:layout_marginBottom="20dp"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="20dp"
        android:text="@string/make_it_your_own"
        android:textColor="@color/sportzone_green"
        android:textSize="35sp" />
</RelativeLayout>

<LinearLayout
    android:id="@+id/add_tournament_name_ll"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/edit_text_wraper"
    android:layout_marginTop="14dp"
    android:background="@color/add_tournament_red_color"
    android:visibility="invisible" >

    <com.threefishmedia.sportzone.views.TextViewCustomFont
        android:id="@+id/information_to_user_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="3dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="3dp"
        android:text="@string/add_tournamnet_name"
        android:textColor="@color/white"
        android:textSize="20sp" />
</LinearLayout>

<RelativeLayout
    android:id="@+id/tournamnet_make_it_your_own_next_btn"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_marginTop="5dp"
    android:layout_below="@+id/add_tournament_name_ll"
    android:background="@color/transperent_black"
    android:clickable="true"
    android:enabled="false" >

    <com.threefishmedia.sportzone.views.TextViewCustomFont
        android:id="@+id/make_iyt_your_own_next_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:layout_marginBottom="30dp"
        android:layout_marginTop="30dp"
        android:text="@string/next"
        android:textColor="@color/disables_btn_text_color"
        android:textSize="@dimen/next_btn_font" />
</RelativeLayout>

<RelativeLayout
    android:id="@+id/invite_friends_rl"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="5dp"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/tournamnet_make_it_your_own_next_btn"
    android:background="@color/transperent_sportzone_green" >

    <com.threefishmedia.sportzone.views.TextViewCustomFont
        android:id="@+id/invites_friends_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:layout_marginBottom="20dp"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="20dp"
        android:text="@string/invite_your_friends"
        android:textColor="@color/sportzone_green"
        android:textSize="35sp" />
</RelativeLayout>

<RelativeLayout
    android:id="@+id/edit_text_wraper"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/make_it_your_own" >

    <com.threefishmedia.sportzone.views.TextViewCustomFont
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="15dp"
        android:layout_marginTop="20dp"
        android:text="@string/tournament_name"
        android:textColor="@color/white"
        android:textSize="30sp" />

    <EditText
        android:id="@+id/tournament_name_et"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignLeft="@+id/textView1"
        android:layout_below="@+id/textView1"
        android:layout_marginRight="20dp"
        android:background="@drawable/rounded_et"
        android:ems="10"
        android:inputType="text"
        android:maxLength="30"
        android:paddingLeft="20dp"
        android:textSize="30sp" >

        <requestFocus />
    </EditText>

    <com.threefishmedia.sportzone.views.TextViewCustomFont
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/tournament_name_et"
        android:layout_below="@+id/tournament_name_et"
        android:layout_marginTop="26dp"
        android:text="@string/jeckpot"
        android:textColor="@color/white"
        android:textSize="30sp" />

    <EditText
        android:id="@+id/jeckpot_amont_et"
        android:layout_width="220dp"
        android:layout_height="50dp"
        android:layout_alignLeft="@+id/textView2"
        android:layout_below="@+id/textView2"
        android:background="@drawable/rounded_et"
        android:ems="10"
        android:inputType="number"
        android:maxLength="9"
        android:paddingLeft="20dp"
        android:textSize="35sp" />

    <ImageView
        android:id="@+id/tournamentt_type_instructions_iv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/jeckpot_amont_et"
        android:layout_alignRight="@+id/tournament_name_et"
        android:clickable="true"
        android:src="@drawable/question" />

    <com.threefishmedia.sportzone.views.TextViewCustomFont
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/tournamentt_type_instructions_iv"
        android:layout_toRightOf="@+id/textView1"
        android:text="@string/tournament_type"
        android:textColor="@color/white"
        android:textSize="30sp" />

    <Switch
        android:id="@+id/basic_expert_switcher"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/jeckpot_amont_et"
        android:layout_alignBottom="@+id/jeckpot_amont_et"
        android:layout_toRightOf="@+id/textView1"
        android:textOff="@string/basic"
        android:textOn="@string/expert"
        android:thumb="@drawable/thumb_selector"
        android:track="@drawable/switch_bg" />

</RelativeLayout>

the problem is when the uses taps on the second EditText the keyboard hides it and the user can't see what he is typing. i worked on it for to long... i have added

android:windowSoftInputMode="adjustResize"

and adjustpan in Manifest file , none of them helped.

any ideas?

like image 701
Gal Rom Avatar asked May 19 '14 05:05

Gal Rom


People also ask

How do I prevent the soft keyboard from pushing my view up in fragment?

Setting android:isScrollContainer = "false" inside the ScrollView worked for me. According to the documentation, settings "isScrollContainer" to true means that the scroll view can be resized to shrink its overall window so that there is space for an input method.

What attribute of EditText can open keyboard according to its type?

The EditText is a user interface which is used for entering and changing the text. While using edit text in XML layout, we must specify its inputType attribute which configures the keyboard according to input type mention.

How do you close hide the Android soft keyboard programmatically?

Hiding the Soft Keyboard Programmatically You can force Android to hide the virtual keyboard using the InputMethodManager, calling hideSoftInputFromWindow, passing in the token of the window containing your edit field. This will force the keyboard to be hidden in all situations.


1 Answers

Put this line inside oncreate,

 getWindow().setSoftInputMode(
                WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
like image 154
Sreedhu Madhu Avatar answered Oct 16 '22 09:10

Sreedhu Madhu