seekbar改变屏幕亮度

sb.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
            
            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                // TODO Auto-generated method stub
                
            }
            
            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
                // TODO Auto-generated method stub
                
            }
            
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress,
                    boolean fromUser) {
                // TODO Auto-generated method stub
                changeP((float)progress/100);
            }
        });
        
    }
    //设置屏幕亮度
    private void changeP(float f){
        WindowManager.LayoutParams param = getWindow().getAttributes();
        //设置屏幕亮度
        param.screenBrightness = f;
        getWindow().setAttributes(param);
    }

 

posted @ 2015-10-19 11:46  aaddrrooiidd  阅读(204)  评论(0编辑  收藏  举报