In my main activity there is a RelativeLayout
that has 2 childs:
ImageView
which serves as the backgroundLinearLa
To change the mode to “resize” at the following statement to your activity in “AndroidManifest.xml”.
<activity android:name=".ActivityName" android:windowSoftInputMode="adjustResize">
and please remove the complexity of LinearLayout ( means you are using multiple level of LinearLayout ) instead of that you can use RelativeLayout also .. using this you can easily set Layout as you want .. try it that also hope your problem may rectifier
I hope this helps.
When the soft keyboard appears on the screen, the amount of space available for the application's UI reduces. The system makes decision on how to organize the available space between the application's UI and soft keyboard.
ListView
, ScrollView
, the application's window is resized provided all the content is visible.pan and scan
approach is used, which simply involves scrolling the application's window so that the currently focused view is visible.Since your layout does not contain any ListView
, ScrollView
, re-sizing is ruled out.
The window's root view is a FrameLayout
to which you were originally adding LinearLayout
. Since LinearLayout
does not support scrolling, pan and scan
approach is also ruled out. Hence wrapping the layout inside ScrollView solves the scrolling issue.
You can refer Android Developers blog for more details.
Update 1:
OP was able to solve the issue, as indicated in this answer. The issue was happening due to one fragment overlaying another fragment after animation and the parent of these Fragment
's was a LinearLayout
. For overlay purpose, you need to use RelativeLayout
or FrameLayout
only.
You can use this code in your Fragment also
This code provide help for resize view
public static class MyDialog extends DialogFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Dialog layout inflater code
// getDialog() need to be called only after onCreateDialog(), which is invoked between onCreate() and onCreateView().
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN | WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
// return view code
}
}
Add this line of code in DialogFragment Oncreateview below R.layout.layout_ui
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN | WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
Use this in onCreateDialog in BottomSheetFragment / Dailogfragment
KeyboardUtil(getActivity(), view);
or
For fragment use
new KeyboardUtil(this, findViewById(R.id.fragment_container));
by using this Util class
https://github.com/mikepenz/MaterialDrawer/blob/aa9136fb4f5b3a80460fe5f47213985026d20c88/library/src/main/java/com/mikepenz/materialdrawer/util/KeyboardUtil.java
Credit:Mikepenz
Turns out my problem was caused by a completely unexpected source.
What happened is that I used a LinearLayout
as the parent of my two fragment containers.
Then, in my expanding animation I raised the bottom container to overlap the other one.
I don't really know why but since LinearLayout
is not supposed to hold overlapping children, switching to a RelativeLayout
or a FrameLayout
immediately solved the issue.
Since this cause might not be apparent from the code I posted, I do want to apologize for the lack of information, and will credit the most detailed answer as the best one.