Soft Keyboard Hiding ActionBar while using adjustPan
Asked Answered
A

3

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

Anabiosis answered 17/6, 2014 at 7:38 Comment(6)
post the xml for that problemFroe
I faced similar issues in my project. My solution was to use a scrollview and place every view inside it. But you have a listview.Thrombo
Yes, i need to use it, coz i am working on an app like a contact manager.Anabiosis
try setting gravity"bottom" to your edittextThrombo
@IllegalArgument , Not WorkingAnabiosis
Have you found a solution for this?Execratory
F
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.

Froe answered 17/6, 2014 at 7:49 Comment(9)
` android:paddingBottom="15dp" `...still not working, tried different values.Anabiosis
@BSTKaal can you post an image when you open edittextFroe
@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.Froe
@BSTKaal nope there no another alternative without it being squeez/resized. I think the only way is adjustSpan just dont mind about the actionbar.Froe
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...Anabiosis
@BSTKaal then they dont regular actionbar, they are using view as an actionbar and they position it each time the edittext is called .Froe
@BSTKaal anytime. :))Froe
@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.Norling
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.Rutland
I
4

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

Izzy answered 17/12, 2014 at 2:49 Comment(2)
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 blog.vogella.com/2010/10/25/android-windowsoftinputmode if you need further explanation. I don't really know stateHiddenbut I guess it makes the keyboard not stay when the input view gets unfocused.Kosaka
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: developer.android.com/guide/topics/manifest/…Izzy
F
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.

Froe answered 17/6, 2014 at 7:49 Comment(9)
` android:paddingBottom="15dp" `...still not working, tried different values.Anabiosis
@BSTKaal can you post an image when you open edittextFroe
@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.Froe
@BSTKaal nope there no another alternative without it being squeez/resized. I think the only way is adjustSpan just dont mind about the actionbar.Froe
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...Anabiosis
@BSTKaal then they dont regular actionbar, they are using view as an actionbar and they position it each time the edittext is called .Froe
@BSTKaal anytime. :))Froe
@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.Norling
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.Rutland
K
0

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

Koerlin answered 20/7, 2015 at 12:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.