15

In my Android application running in a XOOM device, when I click in an Edittext the keyboard opens and hides the Actionbar. I don't want this to happen, how can I solve this? This is done by the Google Contacts app for the tablet for example.

EDIT: I have several edittexts in which the user needs fo fill. At first, when the user clicked on one edittext on the bottom, the keyboard showed up and hide the edittext in which the user was typing, so he couldn't see what he was typing. I found it really bad, and to solve it I just added to the manifest: android:windowSoftInputMode="stateVisible|adjustPan" But after that, now the screen adjust itselfs and hides the action bar.

The Google Contacts app does the same, but it magically doesn't hide the Action bar. How do they do it?

Paulo Barros
  • 2,600
  • 7
  • 24
  • 35

1 Answers1

32

Use adjustResize instead of adjustPan. The framework will always try to keep the focused element on-screen by scrolling any parent views if necessary.

If your EditText field is not nested in some sort of scrolling container such as a ScrollView then your layout may be too tall to completely display when the keyboard resizes your activity. Try wrapping your form's layout in a ScrollView. This will also allow your app's content to scroll if it is running on a smaller screen device where it may have similar issues.

adamp
  • 28,362
  • 8
  • 79
  • 68
  • 2
    But I dont't want to resize it. It's no problem for me to hide some content. The only content thats needs to be on the screen is the selected edittext and the actionbar. Just like the Google Contacts does. How do they do it? – Paulo Barros Nov 28 '11 at 12:13
  • They do it by using adjustResize. :) If you are having trouble with the keyboard obscuring your content (and you will on some devices with different screen sizes or taller keyboards) then you really do want the resizing behavior. This lets you use scrolling containers to keep the activity content accessible with the keyboard open. – adamp Nov 28 '11 at 19:41
  • 5
    Thank you. I needed both adjustResize and a scrollview together. – Paulo Barros Nov 29 '11 at 10:24
  • 5
    I have this problem also but the difference is, i have a list above my edittext and can't use a scrolling container. If I use adjustResize when the edittext is focused it appears above the list and the last items from the list get obscured (list is not pushed up). If I don't use adjustResize on the other hand, when the edittext is focused it pushes everything up but the acionbar is hidden and also I cannot scroll to the top of the list. Can someone share a solution for this? – Sandra Dec 25 '14 at 13:17
  • @Sandra how did you solve your problem? i am running into the same now. – 55597 Jun 08 '15 at 10:04
  • I am also looking solution to the exact same problem. Have spend hours to try everything, still no luck. – zeeshan Jun 12 '16 at 10:47