admin管理员组文章数量:1516870
SeekBar seekBar = (SeekBar) findViewById(R.id.seekBar);
// 进度条绑定最大亮度,255是最大亮度
seekBar.setMax(255);
// 取得当前亮度
int normal = Settings.System.getInt(getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS, 255);
// 进度条绑定当前亮度
seekBar.setProgress(normal);
seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// 取得当前进度
int tmpInt = seekBar.getProgress();
// 当进度小于80时,设置成80,防止太黑看不见的后果。
if (tmpInt < 80) {
tmpInt = 80;
}
// 根据当前进度改变亮度
Settings.System.putInt(getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS, tmpInt);
tmpInt = Settings.System.getInt(getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS, -1);
WindowManager.LayoutParams wl = getWindow().getAttributes();
float tmpFloat = (float) tmpInt / 255;
if (tmpFloat > 0 && tmpFloat <= 1) {
wl.screenBrightness = tmpFloat;
}
getWindow().setAttributes(wl);
}
@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
}
});版权声明:本文标题:从SWF到Android:轻松转换屏幕亮度,掌握NIT单位技巧! 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.betaflare.com/biancheng/1773233586a3277129.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论