【发布时间】:2014-10-14 09:50:27
【问题描述】:
我正在尝试创建一个带有自定义进度条的简单对话框。 但由于某种原因,我只能使背景完全半透明(通过添加 Theme_Translucent_NoTitle)或完全变暗(通过从主题中删除半透明)。
不过,我想做的是能够玩转暗淡的数量。代码如下:
public class ProgressWheelDialog extends Dialog{
private ProgressWheel pw;
public ProgressWheelDialog(final Context ctx) {
// to make transparent background, add Translucent after Theme_
super(ctx, android.R.style.Theme_NoTitleBar);
setContentView(R.layout.dialog_progresswheel);
// dim background
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
layoutParams.dimAmount = .5f;
getWindow().setAttributes(layoutParams);
// get and spin progress wheel
pw = (ProgressWheel) findViewById(R.id.pw_spinner);
pw.setVisibility(ProgressWheel.VISIBLE);
pw.spin();
}
我做错了什么?上面的代码使屏幕完全变暗(当然除了进度条)
【问题讨论】:
-
调用“getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);”在“getWindow().setAttributes(layoutParams);”之后
-
@kozaxinan 它仍然无法正常工作
标签: java android dialog themes