-1

I created a PopUp using the following code:

JAVA:

public class PopUp extends Activity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.activity_pop_up);

        DisplayMetrics dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);

        int width = dm.widthPixels;
        int height = dm.heightPixels;

        getWindow().setLayout((int) (width * 0.6), (int) (height * 0.6));


}

Style XML

<style name="AppTheme.CustomTheme">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowNoTitle">true</item>
    </style>

Well, my popUp is good but i want a background half transparent behind it, not fully transparent as it is. I want something like this:

Activity without popUp:

Activity without popUp

Activity with popUp:

Activity with popUp

Can someone help me? Thanks.

madhan kumar
  • 1,560
  • 2
  • 26
  • 36
gui5711
  • 50
  • 7
  • possible [duplicate](http://stackoverflow.com/questions/2176922/how-to-create-transparent-activity-in-android) -- just use non-00 alpha channel values – kirinthos Jun 21 '16 at 03:00

1 Answers1

0
    Dialog dialog = new Dialog(this, R.style.AppTheme_NoActionBar);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

    ColorDrawable dialogColor = new ColorDrawable(Color.BLACK);
    dialogColor.setAlpha(200);
    dialog.getWindow().setBackgroundDrawable(dialogColor);
    dialog.setContentView(R.layout.activity_result);


    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();

and set alpha accordingly.

K. Gandhi
  • 176
  • 6