0

enter image description here The first picture is SOFT_INPUT_ADJUST_RESIZE. The screen does not go up, but the edittext is not visible.

The second picture is for SOFT_INPUT_ADJUST_PAN. The editText is visible, but the screen is cut off and raised.

How do I make the screen not cut and the edittext visible?

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_chat);

    WindowManager.LayoutParams  layoutParams = new WindowManager.LayoutParams();
    layoutParams.flags  = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
    layoutParams.dimAmount  = 0.5f;
    getWindow().setAttributes(layoutParams);

    Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    int width = (int) (display.getWidth() * 0.85);
    int height = (int) (display.getHeight() * 0.85);
    getWindow().getAttributes().width = width;
    getWindow().getAttributes().height = height;

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);//or resize
samgakhyeong
  • 534
  • 5
  • 7
psj
  • 37
  • 1
  • 8
  • I'm not sure of what you're trying to do. What is the expected? – Eselfar Dec 22 '20 at 02:34
  • The goal is to make the editText visible without the top of the screen being cut off. – psj Dec 22 '20 at 04:11
  • https://stackoverflow.com/questions/7417123/android-how-to-adjust-layout-in-full-screen-mode-when-softkeyboard-is-visible/19494006#19494006 solved... thank you! – psj Dec 22 '20 at 06:12
  • Like they said, it won't work with fullscreen. Beyond that- what you want is resize, but for that to work your layout needs to be resizable- there needs to be some part of your screen that can shrink. Which all depends on what constraints and sizes you have on your layout. – Gabe Sechan Dec 22 '20 at 07:06

1 Answers1

0

you can add this line to your AndroidManifest.xml

android:windowSoftInputMode="adjustPan|adjustResize"

OR

also you can add it programmatically in java file like below

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

OR

You can also manage these things by using design layout in vertical scroll view so once user click on the edit text then the content of the page will be scroll vertically and you can see whole page.

Sumit Patel
  • 379
  • 3
  • 8