Androidで画面の明るさをどのように設定しますか?
-
27-10-2019 - |
質問
画面の明るさを使用して調整するダイアログが必要です SeekBar
.
カスタムダイアログを表示する方法 SeekBar
それは画面の明るさを調整しますか?
解決
このAPIを使用できます. 。これにより、システム全体ではなく、ウィンドウの画面の明るさが変更されます。
// Make the screen full bright for this activity.
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = 1.0f;
getWindow().setAttributes(lp);
他のヒント
これ コードスニペット あなたを助けるべきです
pdlg = ProgressDialog.show(getParent(), "Loading...", "");
WindowManager.LayoutParams lp = pdlg.getWindow().getAttributes();
p.dimAmount=0.0f; //Dim Amount
pdlg.getWindow().setAttributes(lp); //Applying properties to progress dialog
pdlg.dismiss(); //Dismiss the dialog
ねえ、あなたはこのようなシステムの明るさを設定することができます:
//Set the system brightness using the brightness variable value
System.putInt(cResolver, System.SCREEN_BRIGHTNESS, brightness);
//Get the current window attributes
LayoutParams layoutpars = window.getAttributes();
//Set the brightness of this window
layoutpars.screenBrightness = brightness / (float)255;
//Apply attribute changes to this window
window.setAttributes(layoutpars);
または、この完全な参照を参照してください チュートリアル
所属していません StackOverflow