Is there any way to change android:windowSoftInputMode value from java class?

后端 未结 5 1282
悲哀的现实
悲哀的现实 2020-12-02 12:00

I want to act my tabs to have different windowSoftInputMode properties for each tab. How to access this property from java class when all handling of your tab

5条回答
  •  春和景丽
    2020-12-02 12:27

    I aim to use two different modes for tabs. The modes are SOFT_INPUT_ADJUST_RESIZE and SOFT_INPUT_ADJUST_NOTHING.

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

    The code line above simply doesn't work by itself. App always behaves in a state ADJUST_NOTHING. However, if windowSoftInputMode="adjustResize" is inserted into tag in AndroidManifest.xml file, app window is resized as default. Additionally, when you call following line

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

    it will behave as expected and nothing is resized.

    P.S. improvement to the answer

提交回复
热议问题