基类里面加toolBar后,子类的recyclerView/scrollView里面item的edittext 软键盘遮挡问题

最近遇到的一个问题,基类里面有toolbar,子类里面recyclerView/scrollView里面item的edittext 软键盘被遮挡;

测试了,没有加toolbar的activity没有问题,不会遮挡;

toolbar直接加在activity里面,没问题,不会遮挡;

但是,toolbar放基类里面,就会出现问题。




    

        

        

            

        
    

    
    

解决:

在基类或者子类的oncreate里面加:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN |
        WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

 

SOFT_INPUT_ADJUST_PAN 是调整窗口视图,避免遮挡; SOFT_INPUT_STATE_ALWAYS_HIDDEN 是防止一进来activity就弹出软键盘的.
/** Adjustment option for {@link #softInputMode}: set to have a window
 * pan when an input method is
 * shown, so it doesn't need to deal with resizing but just panned
 * by the framework to ensure the current input focus is visible.  This
 * can not be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if
 * neither of these are set, then the system will try to pick one or
 * the other depending on the contents of the window.
 */

要加在oncreate里面才可以,在manifest里面加这个属性没有作用

一个博客:

如何解决软键盘弹出引起的各种不适

http://unicorn25.iteye.com/blog/916504

 

 

你可能感兴趣的:(Android,安卓开发遇到问题总结)