1

How do I display a Popup Window without XML and show a custom image? I have not found any working examples.

Tried this:

public void showMenu() {
    PopupWindow myWindow=new PopupWindow(this);
    LinearLayout mainLayout = (LinearLayout) findViewById(R.id.main_layout);
    myWindow.setBackgroundDrawable(ContextCompat.getDrawable(this, R.drawable.dashboard_instructions));
    myWindow.showAtLocation(mainLayout, Gravity.CENTER, 0, 0);
quantumpotato
  • 9,637
  • 14
  • 70
  • 146

1 Answers1

0

Idea in my mind is you can add custom image as a background of popup window, Not able to test right now, below is the idea hope it will get a clue for you.

    PopupWindow myWindow=new PopupWindow(this);
    myWindow.showAtLocation(ANY_VIEW_FOR_WINDOW_TOKEN, Gravity.CENTER, 0,0);
    myWindow.setBackgroundDrawable(getDrawable(R.drawable.abc));

getDrawable() call requires Target API 21, Hope it will works.

Akber
  • 521
  • 4
  • 10