Press contents when pressed in a text editor

I searched everywhere to solve my problem, but can not find the answer. Here is the problem.

I have a layout that looks like

Image is here

Now when I click on the edit text (search bar), I want the following to happen

Image is here

The soft keyboard should basically push the contents of all screens so that the search bar is at the top of the screen and its list is below it so that the results are displayed when searching for content. I tried to set android:windowSoftInputMode="adjustPan" in the Activity in the manifest, but that did not work. I set the scroll view as the main container in the main layout, which contains fragments, but this also did not work. I tried to add the edit text (search bar) as a title to the list, but that also didn't work. Each time the keyboard pushed the edit text, but closed the list view. Is there any way to make this work?

+53
android
Jul 02 2018-12-12T00:
source share
10 answers

In fact, if you want the whole layout to be included, you should use:

SOFT_INPUT_ADJUST_PAN

value:

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

this will close the keyboard, and when it opens, it will fully activate your activity.

+64
Jan 18 '15 at 17:17
source share

This can be used in the fragment class to move the Edit text up and scroll to the end.

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

This will work if your fragmentation theme is not included in FullScreen.

Hope this helps!

+17
Apr 17 '14 at 10:12
source share

It worked for me.

 getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); 
+10
Jun 14 '14 at 14:26
source share

I ran into a similar problem, the solution was simple.

If the theme in action is set to fullscreen @android:style/Theme.Holo.NoActionBar.FullScreen , the keyboard did not push the content up.

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

+8
Dec 19 '12 at 18:11
source share

try it

 android:windowSoftInputMode="adjustResize" 

I work for me.

+8
Oct 16 '15 at 15:08
source share

Try android:windowSoftInputMode="adjustResize" in your manifest file.

You may need android:windowSoftInputMode="adjustResize|adjustPan" ... I have nothing comparable to your installation to check ...

Your problem is this (from the docs for adjustPan, my hit):

The main operation window does not change to make room for a soft keyboard. Rather, the contents of the window automatically expand so that the current focus is never closed by the keyboard and users can always see what they are typing.

Given that your list is closed because EditText is focused on top. The only thing I can think of right now is move the EditText so that it is below the list. Then, when you click up, your list should remain visible above the EditText.

+6
Jul 02 2018-12-12T00:
source share

I could not find a solution to automatically change the layout, so I had to hack it. I used the code that I found here in my main action to detect when the keyboard is open. I just added code to call a method that hides my first two snippets when I open the keyboard. This is not what I wanted to do, but it works.

+3
Jul 04 2018-12-12T00:
source share

This worked for me, for the fragment, just declare it in the manifest with activity:

 android:windowSoftInputMode="adjustPan" 

Good luck

+2
Nov 04 '16 at 10:34
source share

I use this for my EditText login:

 this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); 

Some notes about this method:

this refers to context since getActivity() not always preferable

 .SOFT_INPUT_STATE_HIDDEN //for default hidden state when activity loads .SOFT_INPUT_STATE_VISIBLE //for auto open keyboard when activity loads 

It works every time!

+1
Nov 23 '14 at 1:50
source share

If anyone else encounters this problem:

 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:id="@+id/view" **android:fitsSystemWindows="true"** android:layout_height="match_parent"> 

add to your layout:

 android:fitsSystemWindows="true" 

Hope this solves your problem - it worked for me.

0
Dec 21 '16 at 10:50
source share



All Articles