6

I need to set visible all these three items
1. ActionBar
2. ListView
3. EditText (at Bottom)
When i click on EditText, it pushed the background image and squeezed it. i saw some tutorials and used android:windowSoftInputMode="adjustPan" that solved the squeezing issue but created a new one. When the SoftKeyboard appears, it also hides the ActionBar. I have visited many questions , but none of them was actually helpfull. IS there any way to set ActionBar always visible whatever happening on screen etc...

EDITED

The xml of fragment used to display the ListView and EditText is :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >


    <ListView
        android:id="@id/android:list"
        style="@style/ContactListView"
        android:layout_width="match_parent"
        android:layout_height="389dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:isScrollContainer="false" />

    <TextView
        android:id="@id/android:empty"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:layout_above="@+id/editText1"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:fontFamily="sans-serif-light"
        android:gravity="center"
        android:text="@string/no_contacts"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentBottom="true"
        android:background="@android:color/holo_blue_dark"
        android:ems="10" 
        android:imeOptions="flagNoExtractUi"/>

</RelativeLayout>

Edited (2nd)

Snapshots are:

enter image description here enter image description here

BST Kaal
  • 2,993
  • 6
  • 34
  • 52

3 Answers3

4

Try using android:windowSoftInputMode="adjustResize|stateHidden" in your activity tag.

Nathan Tuggy
  • 2,237
  • 27
  • 30
  • 38
codezjx
  • 9,012
  • 5
  • 47
  • 57
  • I thought this lacks an explanation, so I'll try to explain. AdjustPan simply moves everything upwards, some stuff maybe out of the screen, so that the focused View is visible even though the keyboard takes some space away. adjustResize tries to resize your stuff in such a way, that all views will still be visible. See http://blog.vogella.com/2010/10/25/android-windowsoftinputmode/ if you need further explanation. I don't really know `stateHidden`but I guess it makes the keyboard not stay when the input view gets unfocused. – lucidbrot Mar 01 '16 at 16:39
  • Yes, "adjustResize" always resized activity's main window to make room for the soft keyboard on screen, but "adjustPan" cause the window are automatically panned. BTW, "stateHidden" usually use in situation above, when enter the activity, the edittext will not cause keyboard show. For more information, you can visit: http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft – codezjx Mar 02 '16 at 02:24
2

I have the same problem as yours with EditText inside a Relative layout before, after searching several thread all over internet I have failed, but I solve it by experimenting on it through adding bottom_padding to the EditText which fixed it.

Rod_Algonquin
  • 26,074
  • 6
  • 52
  • 63
  • ` android:paddingBottom="15dp" `...still not working, tried different values. – BST Kaal Jun 17 '14 at 07:55
  • @BSTKaal can you post an image when you open edittext – Rod_Algonquin Jun 17 '14 at 07:59
  • 1
    @BSTKaal based on the picture you posted that it what it would look like when you set your windowSoftInputMode to adjustSpan there is nothing you can do about it. What I posted as an answer is totally different problem. – Rod_Algonquin Jun 17 '14 at 08:24
  • @BSTKaal nope there no another alternative without it being squeez/resized. I think the only way is adjustSpan just dont mind about the actionbar. – Rod_Algonquin Jun 17 '14 at 08:43
  • Then How its working in **Whats App**?? When you select a contact for chat, and click on edit text, there is no squeezing of background image and action bar is still visible... – BST Kaal Jun 17 '14 at 08:47
  • 1
    @BSTKaal then they dont regular actionbar, they are using view as an actionbar and they position it each time the edittext is called . – Rod_Algonquin Jun 17 '14 at 08:57
  • @BSTKaal anytime. :)) – Rod_Algonquin Jun 17 '14 at 09:03
  • 1
    @BSTKaal I think that for WhatsApp and Hangouts, it works by using adjustResize, and only if you are already on the bottom, it will scroll to the bottom. – android developer Sep 14 '14 at 12:31
  • 1
    How did adding a bottom_padding fix your problem. I'm trying to fix a similar problem but it's a form, and I'm not in control of the paddings of the form fields. Kindly share if you know why your solution fixed the problem. It can possibly give me an idea for my problem. – Prateek Sep 24 '14 at 16:47
0

try this code to manifest file and activity to change layout. android:windowSoftInputMode="stateAlwaysVisible|stateHidden"

Ram Lakhan
  • 79
  • 5