ᴛʜᴇᴘᴀᴛᴇʟ
ᴛʜᴇᴘᴀᴛᴇʟ

Reputation: 4656

Android custom popup

So I have a layout I created and I want to use that as a popup on a different layout.

I was able to figure out how to call it but it doesn't look right. It called the ENTIRE layout, not just the content of it.

This is what I did:

this.textAbsType.Click += (object sender, EventArgs e) => {
    View absenceTypePopup = LayoutInflater.Inflate(Resource.Layout.AbsenceTypePopup, null);

    Dialog absenceTypeDialog = new Dialog(context);
    absenceTypeDialog.SetContentView(absenceTypePopup);
    absenceTypeDialog.Show();

    this.btnAbsTypePopupClose = absenceTypeDialog.FindViewById<Button> (Resource.Id.btnAbsTypePopupClose);

    this.btnAbsTypePopupClose.Click += (object sender2, EventArgs e2) => {
        absenceTypeDialog.Dismiss();
    };
};

So when textAbsType (TextView) is called, popup is shown. And 2nd event if for the button on the popup to cancel it.

But this is how the popup shows up:

Simulator Screenshot

The extra black border on the top is part of the axml design file.

Question: How can I get rid of that so I can just view the TableLayout as the popup?

Thank you for your time.

Upvotes: 1

Views: 271

Answers (1)

Tushar Gogna
Tushar Gogna

Reputation: 5083

Just add the line absenceTypeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); in your code and it will go away.

Updated code:

this.textAbsType.Click += (object sender, EventArgs e) => {

    Dialog absenceTypeDialog = new Dialog(context);
    absenceTypeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    absenceTypeDialog.setContentView(R.layout.AbsenceTypePopup);
    absenceTypeDialog.Show();

    this.btnAbsTypePopupClose = absenceTypeDialog.FindViewById<Button> (Resource.Id.btnAbsTypePopupClose);

    this.btnAbsTypePopupClose.Click += (object sender2, EventArgs e2) => {
        absenceTypeDialog.Dismiss();
    };
};

Upvotes: 2

Related Questions