Question

Hide EditText when appear android Keybord

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/relativeLayout1"
android:layout_width="fill_parent" android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/main_bg" 
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

>

<RelativeLayout android:layout_width="match_parent"
    android:layout_height="40dip" android:layout_alignParentTop="true"
    android:background="@drawable/tab_bar" android:id="@+id/rel_jobDesc">

 <!--   <Button android:id="@+id/option"
         style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"  android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"  
        android:background="@drawable/skills"
        android:layout_centerVertical="true" android:text=""
         ></Button> 
         -->

    <TextView android:layout_width="wrap_content" android:id="@+id/txt_SEARCH_TITLE"
        android:layout_height="wrap_content" android:layout_centerInParent="true"
        android:text="Job Search" android:textStyle="bold"  android:textSize="20dip"
        android:textColor="#fff"></TextView>
    <Button android:id="@+id/btnAboutus"
        android:layout_width="wrap_content"  android:layout_height="wrap_content"
        android:layout_alignParentRight="true"   android:background="@drawable/draw"
        android:layout_centerVertical="true" android:text="@string/about_us"
         ></Button>

    <Button
        android:id="@+id/option"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_margin="4dip"
        android:text="@string/back"
        android:background="@drawable/small" />

</RelativeLayout>

<LinearLayout
    android:id="@+id/l1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/rel_jobDesc" >

   <ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
   android:layout_below="@+id/logo"

   android:layout_marginTop="10dp"

   android:layout_marginLeft="2dp"
    android:layout_marginRight="2dp" >


 <RelativeLayout android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:layout_marginTop="55dip" android:layout_marginLeft="2dip"
    android:layout_marginRight="2dip">


<!--JOB DESCRIPTION -->
<TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:id="@+id/txt_JOB_DESCRIPTION"
    android:layout_marginLeft="10dip" android:text="@string/job_desc"
    android:layout_marginTop="20dip"
     android:textStyle="bold"
    android:textSize="14dip" android:textColor="#000000"
    ></TextView>
 <EditText
     android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:id="@+id/edit_JOB_DESCRIPTION"
    android:layout_toRightOf="@+id/txt_JOB_DESCRIPTION"
    android:maxLines="1" 
     android:background="@android:drawable/editbox_background"
    android:singleLine="true"
     android:capitalize="characters"
    android:layout_marginTop="10dip" android:layout_marginRight="20dip"
    ></EditText>
<TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:id="@+id/txt_JDESCRIPTION"
    android:layout_marginLeft="45dip" android:text="@string/job_title"
    android:textSize="12dip" android:textColor="#4a596e"
    android:layout_below="@+id/edit_JOB_DESCRIPTION"
    android:layout_centerInParent="true"></TextView>
<!-- -->

<!--LOCATION -->

<TextView
    android:id="@+id/txt_JOB_LOCATION"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/txt_JDESCRIPTION"

    android:layout_marginTop="50dip"
   android:layout_marginLeft="10dip"
    android:text="@string/location"
    android:textColor="#000000"
    android:textSize="15dip"
    android:textStyle="bold" >
</TextView>

<EditText
android:id="@+id/edit_JOB_LOCATION"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/edit_JOB_DESCRIPTION"
android:layout_below="@+id/txt_JDESCRIPTION"
android:layout_marginRight="20dip"
android:layout_marginTop="40dip"
android:background="@android:drawable/editbox_background"
android:maxLines="1"
android:capitalize="characters"
android:singleLine="true" >
</EditText>
<TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:id="@+id/txt_JLOCATION"
    android:layout_marginLeft="45dip" android:text="@string/city_state"
    android:textSize="12dip" android:textColor="#4a596e"
    android:layout_below="@+id/edit_JOB_LOCATION"
    android:layout_centerInParent="true"></TextView>
<!-- -->


<!-- JOB ID -->
<!-- -->



<!-- SEARCH BUTTON -->

<Button
    android:id="@+id/btn_SEARCH"
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:layout_below="@+id/txt_JLOCATION"
    android:layout_centerInParent="true"
    android:layout_marginTop="40dip"
    android:background="@drawable/draw"
    android:text="@string/search" >
 </Button>
<!-- -->

</RelativeLayout>

</ScrollView>

  </LinearLayout>

  <com.google.ads.AdView android:id="@+id/adView"
                     android:layout_width="fill_parent"
                     android:layout_height="wrap_content"
                   android:layout_alignParentBottom="true"
                     ads:adUnitId="ca-app-pub-2584288851778590/4570818460"
                     ads:adSize="BANNER"
                     ads:loadAdOnCreate="true"
                     ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"/>
 </RelativeLayout>

Edit text not showing when appear Keyboard i already added android:windowSoftInputMode="adjustPan" in my manifest.xml file Please suggest me . How i can fix this problem. Thanks In Advance.

Was it helpful?

Solution

Try this in your activity:

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
if(getCurrentFocus()!=null)
    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top