1
在我的應用程序中,我在對話框中顯示圖像。如果用戶按下按鈕,則出現對話框並佔用整個屏幕的80%。背景將變暗,因爲這是Android對話框的默認行爲。對話框:除一些區域以外的所有其他區域
Dialog dialog = new Dialog(ActQuiz.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
//nothing;
}
});
int width = (int) (getResources().getDisplayMetrics().widthPixels * 0.80);
int height = (int) (getResources().getDisplayMetrics().heightPixels * 0.80);
dialog.getWindow().setLayout(width, height);
ImageView imageView = new ImageView(ActQuiz.this);
String uri = "@drawable/" + info.getInfopicture();
int imageResource = getResources().getIdentifier(uri, null, getPackageName());
Drawable myDrawable = ContextCompat.getDrawable(ActQuiz.this, imageResource);
imageView.setImageDrawable(myDrawable);
new PhotoViewAttacher(imageView);
dialog.addContentView(imageView, new RelativeLayout.LayoutParams(width, height));
dialog.show();
所以我想實現是禁用調光的按鈕,這是對話框後面可見。
這是可能的,或者我只能去除調光整個背景是什麼?
您可以清除對話框背後的暗淡背景......是嗎? – rafsanahmad007
您可能的意思是:clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHI ND)。但它會消除整個背景的調光。我只想要它的按鈕。你可以在我的帖子中看到它。 –
你可以看看這個:https://stackoverflow.com/questions/14030154/how-to-dim-blur-only-part-of-the-screen – rafsanahmad007