'How do you add windowSoftInputMode to one item

I want to add android:windowSoftInputMode="adjustPan" only to recycler view.

When I add it into the manifest file it adds it to everything which I don't want.

When I add the line of code in the recycler view it doesn't work.



Solution 1:[1]

Simply use below code, don't need to define anything in AndroidManifest file.

 (recyclerView.getLayoutManager() as LinearLayoutManager).stackFromEnd = true

Solution 2:[2]

You can try this. Replace the viewItem with your view

In Java

viewItem.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN)

In Kotlin

viewItem.window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Umesh
Solution 2 Sambhav. K