Search code examples
androidkeyboardwindow-soft-input-mode

android- Use adjustResize and adjustPan on same Activity


I am Developing a chat app which has background chat image and default keyboard,when i have to use background image it shrinks but when i use android:windowSoftInputMode="adjustResize" it works perfectly ,but keyboard hides edittext,if i use android:windowSoftInputMode="adjustPan" keyboard displays perfectly but image shrinks,how can i use both option on single Activity

If i use both option in manifest edittext has been hidden

enter image description here


Solution

  • I'have had the same problem, and I solved it putting adjust settings programmatically when it's needed

    this is the code:

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

    and

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