Currently i have a dialog
that shows an image that is being clicked by the user.
What i want to do, is to add a button
on the bottom
of the dialog
.
This is my current code:
public void showImage(Drawable drawable) {
final Dialog builder = new Dialog(mContext);
builder.setCancelable(true);
builder.setCanceledOnTouchOutside(true);
builder.requestWindowFeature(Window.FEATURE_NO_TITLE);
builder.getWindow().setBackgroundDrawable(
new ColorDrawable(Color.RED));
// builder.getWindow().setBackgroundDrawable(
// new ColorDrawable(android.graphics.Color.TRANSPARENT));
builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
//nothing;
}
});
ImageView imageView = new ImageView(mContext);
Button mClose = new Button(mContext);
mClose.setText("CLOSE");
mClose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
builder.dismiss();
}
});
imageView.setImageDrawable(drawable);
builder.addContentView(imageView, new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
builder.addContentView(mClose,new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
builder.show();
}
The current code have :
The button
is in the upper left of the imageview
where it should be on the below of imageview
.