是否可以通过在屏幕上上下滑动来调整屏幕亮度,我应该使用哪种方法来获得它?
在搜索栏的帮助下我做到了,但知道如何使用滑动手势来完成是很好的,因为它将对其他许多人有帮助。
通过在搜索栏更改侦听器上应用以下方法,可以很容易地使用搜索栏调整屏幕亮度。
public void onStopTrackingTouch(SeekBar seekBar)
{
System.putInt(cResolver, System.SCREEN_BRIGHTNESS, brightness);
LayoutParams layoutpars = window.getAttributes();
layoutpars.screenBrightness = brightness / (float)255;
window.setAttributes(layoutpars);
}
public void onStartTrackingTouch(SeekBar seekBar)
{
//Nothing handled here
}
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
{
if(progress<=20)
{
brightness=20;
}
else
{
brightness = progress;
}
float perc = (brightness /(float)255)*100;
txtPerc.setText((int)perc +" %");
}
});
}
有人知道没有搜索栏怎么做吗?
有点晚了,但是对于那些现在正在寻找它的人来说,你可以使用这个android library Swipper