Android pop-up soft keyboard tops off the navigation bar

There will be strange problems in development. For example, when you click on the input box, the soft keyboard pops up and the navigation bar below will be pushed up. Various gods on the Internet say that attributes should be added to the AndroidManifest.xml file, but all the methods have been tried. Or not. Finally, I thought of a method: monitor when the soft keyboard pops up and hides,
1. Hide the navigation bar when the soft keyboard pops up
getActivity().findViewById(R.id.sports_ll_belowmain).setVisibility(View.GONE);
2. Show the soft keyboard when it disappears
getActivity().findViewById(R.id.sports_ll_belowmain).setVisibility(View.VISIBLE);
3. When the house arrest disk is popped up to switch pages and switch to another fragment, other fragments will not call the interface that the software disk disappears, causing another bug that the navigation bar below is missing. At this time, in order to solve this bug , When the viewPager switches, judge whether the soft keyboard pops up, if it pops up, let it disappear, and whether the navigation bar below is hidden, if it is hidden, let it show.
View view = getActivity().getWindow().peekDecorView();
if (view!=null){
InputMethodManager inputmanger = (InputMethodManager) getActivity()
.getSystemService(MainActivity.INPUT_METHOD_SERVICE);
inputmanger.hideSoftInputFromWindow(view.getWindowToken(),
0);
}
4. The problem encountered at this time is that when switching from this fragment to another fragemnt and then switching back, the soft keyboard does not disappear (the system soft keyboard disappears, and the custom house arrest disk does not disappear. The demand at this time is as long as there is house arrest. The navigation bar below is not allowed to display), and the navigation bar is displayed again. It is to judge the status of the software disk of the page, store its status value in the application class, judge the status code when entering the page next time, and make corresponding operations according to the status code
if (mSportsApp.getSportshow_isshow()==position){
getActivity().findViewById(R.id.sports_ll_belowmain).setVisibility(View.GONE);
}else {
getActivity().findViewById(R.id.sports_ll_belowmain).setVisibility(View.VISIBLE);
}
Continue to make changes and finally achieve the desired effect

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326009172&siteId=291194637