Android 遮罩层控制亮度(PopupWindow)

Activity内使用:

            float brightness = Integer.parseInt(eneity.number); //获取到的实际亮度,如 100 200
            //要用浮点类型除整数,否则结果为0
            float alpha = brightness/255; // 亮度比,本例总亮度为255; 若总亮度为100则 /100
//            Log.e("showPopupWindow", "setData: "+ brightness +"  "+alpha);
            showPopupWindow(alpha);

具体方法:

    public void showPopupWindow(float alpha) {
    
    
        PopupWindow mPop = new PopupWindow(getLayoutInflater().inflate(R.layout.popup_window_layout, null),
                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
        WindowManager.LayoutParams lp =getWindow().getAttributes();
        lp.alpha = alpha;
        getWindow().setAttributes(lp);
    }

猜你喜欢

转载自blog.csdn.net/qq_30297763/article/details/113756939