Activity with fragments does not resize when the keyboard opens

前端 未结 7 1585
挽巷
挽巷 2020-12-08 04:38

In my main activity there is a RelativeLayout that has 2 childs:

  • An ImageView which serves as the background
  • A LinearLa
7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 05:22

    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
      }
    }
    

提交回复
热议问题