Reputation:
final Dialog dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(true);
dialog.setContentView(R.layout.dialog_image);
ImageView dialogIv = (ImageView)dialog.findViewById(R.id.dialog_iv);
TextView dialogTV = (TextView)dialog.findViewById(R.id.dialog_med_name);
dialog.show();
When i click on anywhere on dialog it should dismiss.Full Screen its imageview dialog.
Upvotes: 0
Views: 122
Reputation: 1265
One thing you can do,Just set clicklistner on your Imageview.
dialogIv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
Upvotes: 1
Reputation: 3235
You can create your own Touch Listener, and dismiss the dialog on the UP event.
class MyTouchListener implement OnTouchListener{
public boolean onTouch(View v, MotionEvent event)
{
if(event.getAction() == MotionEvent.ACTION_UP){
// DISMISS DIALOG
}
return true;
}
And then set this listener to your dialog
MyTouchListener l = new MyTouchListener();
dialog.setOnTouchListener(l);
Upvotes: 0
Reputation: 1472
setCanceledOnTouchOutside
Added in API level 1
void setCanceledOnTouchOutside (boolean cancel)
Sets whether this dialog is canceled when touched outside the window's bounds. If setting to true, the dialog is set to be cancelable if not already set.
Parameterscancelboolean: Whether the dialog should be canceled when touched outside the window.
Upvotes: 0