Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top