Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push up content when clicking in edit text

Tags:

android

I have searched everywhere for a solution to my problem but cannot find a answer. Here's the problem.

I have a layout that looks like this

Image is here

Now when I click in the edit text(search bar) i want the following to happen

Image is here

The soft keyboard basically needs to push up the whole screens content so that the search bar is at the top and its listview is beneath it so that when the content is searched the results are displayed. I have tried setting android:windowSoftInputMode="adjustPan" to the Activity in the manifest but this did not work. I set a scroll view as the main container in the main layout that contains the fragments but that also did not work. I have tried adding the edit text(search bar) as a header to the list view but this also did not work. Every time the keyboard pushed up the edit text but covered the list view. Is there any way to make this work?

like image 692
the-ginger-geek Avatar asked Jul 02 '12 11:07

the-ginger-geek


5 Answers

Actually if you want your entire layout pan up than you should use :

SOFT_INPUT_ADJUST_PAN

meaning:

getActivity().getWindow().setSoftInputMode(
                WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

this will keep the keyboard closed and when opened it'll push your entire activity up.

like image 198
David Fischer Avatar answered Nov 10 '22 17:11

David Fischer


This can be used in Fragment Class to move the Edit text up and Scroll till end.

getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

This will work for sure if your Fragment Activity theme is not in FullScreen.

Hope this will help!

like image 32
Dunken_sai Avatar answered Nov 10 '22 17:11

Dunken_sai


I faced a similar issue, the solution was simple.

If the theme in the activity is set as Fullscreen @android:style/Theme.Holo.NoActionBar.FullScreen, the keyboard was not pushing the contents up.

After I changed the activity to @android:style/Theme.Holo.NoActionBar, the keyboard is now pushing the activity contents up.

like image 11
Chandru Avatar answered Nov 10 '22 17:11

Chandru


This worked for me.

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
like image 11
Madhav Avatar answered Nov 10 '22 17:11

Madhav


Try this

android:windowSoftInputMode="adjustResize"

Working for me.

like image 10
Neo Avatar answered Nov 10 '22 18:11

Neo