Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 383
Jaichander Avatar asked Mar 03 '26 11:03

Jaichander


2 Answers

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);
like image 118
Ging3r Avatar answered Mar 06 '26 00:03

Ging3r


According to the documentation those cannot be combined:

android:windowSoftInputMode=["stateUnspecified", "stateUnchanged", "stateHidden", "stateAlwaysHidden", "stateVisible", "stateAlwaysVisible", "adjustUnspecified", "adjustResize", "adjustPan"]

The setting must be one of the values listed in the following table, or a combination of one "state..." value plus one "adjust..." value. Setting multiple values in either group — multiple "state..." values, for example — has undefined results. Individual values are separated by a vertical bar (|). For example:

like image 29
dowi Avatar answered Mar 06 '26 02:03

dowi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!