Android - EditText overlaps with Softkeyboard

I am working on an Activity that has an EditText. When I click / touch the EditText screen panel. But the EditTexts that are at the bottom of the screen overlap with the softkeyboard. The top half of the EditText is displayed, and the bottom half is below the keyboard.

I set android:windowSoftInputMode="adjustPan" in AndroidManifest.xml

Any suggestion on how to avoid it?

+4
source share
2 answers

I think you should take a look at this link. this problem. It seems very similar to the one you have.

+4
source

For me, I did not want to assume that the height of the keyboard is a certain dimension. Whatever you think of creating an onTouchListener, then do the following:

  setOnTouchListener(new OnTouchListener() { Runnable shifter=new Runnable(){ public void run(){ try { int[] loc = new int[2]; //get the location of someview which gets stored in loc array findViewById(R.id.someview).getLocationInWindow(loc); //shift so user can see someview myscrollView.scrollTo(loc[0], loc[1]); } catch (Exception e) { e.printStackTrace(); } }} }; Rect scrollBounds = new Rect(); View divider=findViewById(R.id.someview); myscollView.getHitRect(scrollBounds); if (!divider.getLocalVisibleRect(scrollBounds)) { // the divider view is NOT within the visible scroll window thus we need to scroll a bit. myscollView.postDelayed(shifter, 500); } }); 

// essentially we make a runnable that scrolls to a new location of some kind that you WANT to see on the screen. you execute this runnable only if it is not within scrollviews (its not on the screen). Thus, it moves scrollview to a reference view (in my case, "someview", which was a line separator).

0
source

Source: https://habr.com/ru/post/910911/


All Articles