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