1

I have implemented the ActionBar using v7 support library. The content of the activity below the actionbar are some textviews, editexts and a button.

Now when I tap on the edittext, the keyboard appears and that makes the actionbar moving up and out of the screen. I want the position of the actionbar to be fixed and only the content to scroll up or down as and when required with out affecting the actionbar (like the gmail app in android phones.).

How to achieve that?

Thanks in advance.

Dexter
  • 2,917
  • 2
  • 37
  • 49
  • There are **several** questions on SO about that. Do some searches and you'll find that this attribute: `android:windowSoftInputMode` is what you looking from [this documentation](http://developer.android.com/guide/topics/manifest/activity-element.html). – fllo May 08 '14 at 07:29
  • @Fllo.Thanks for the comment. I had done some searches but could not find a solution to this. Even after going through the link you've provided, I have some doubt. May be I am missing something. Is it due to the keyboard only the ActionBar going out of screen? android:windowSoftInputMode mostly deals with keybaord and activity resizing. Does some scrollable content on the activity won't make the ActinBar moving out of screen and keep it fixed on the top? IMHO, there should be some property to be set for ActionBar. Kindly explain a little more on this. – Dexter May 08 '14 at 07:55
  • In your searches, you maybe missed this question: [Keyboard layout hiding android action bar?](http://stackoverflow.com/questions/8228514/keyboard-layout-hiding-android-action-bar). The ActionBar is moving up because of the keyboard which adjusts the content relative to its height. It might be useful to read this from the docs: [Specify How Your UI Should Respond](http://developer.android.com/training/keyboard-input/visibility.html#Respond) – fllo May 08 '14 at 08:07

1 Answers1

2

Well, I think, I should answer the question with the new understanding of the problem and the solution and to explain the issue to the new user. I did not land on the right link (answer) earlier, because I was of the notion that this is strictly an ActionBar related issue.So my searches were with those sort of keywords not having edittext.

But as rightly pointed by Fllo and this link

the issue was related to Android system's handling of input and re-sizing of activity. So the solution is:

step-1) setting windowSoftInputMode attribute to adjustResize.

 <activity ........... android:windowSoftInputMode="adjustResize"/>

step-2) above step would fix the position of action bar but, the text entered from the keybaord won't be visible when the layoutout is bigger then the screen can adjust. To make the edittext (or other input widgets) and text being typed on it, the layout should be made scrollable by wrapping in a ScrollView.

<ScrollView> your_layout ...</ScrollView>

Now the action bar is fixed. Also the input widget becomes visible as the android system scroll it up above the keyboard to make the text you type visible.

Community
  • 1
  • 1
Dexter
  • 2,917
  • 2
  • 37
  • 49