android studio 软键盘弹出顶底部布局 和 屏幕的百分比方法

底部布局用RelativeLayout固定在底部,软键盘弹出上顶

//软键盘弹出顶底板布局解决办法
        getWindow().setSoftInputMode
                (WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN|
                        WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

 

屏幕的百分比方法

 //屏幕比例
        DisplayMetrics dm = new DisplayMetrics();
        dm = getResources().getDisplayMetrics();
        screenWidth = dm.widthPixels;

RelativeLayout.LayoutParams layoutParams = (android.widget.RelativeLayout.LayoutParams) rl_shopsearch
                            .getLayoutParams();
                    layoutParams.width = (int) (screenWidth * 0.8);
                    rl_shopsearch.setLayoutParams(layoutParams);

 

posted on 2018-03-07 15:55  爱学习的亮亮  阅读(283)  评论(0)    收藏  举报

导航