samedi 25 juin 2016

Create PopUp with background behind it 50% transparent

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 :)

Aucun commentaire:

Enregistrer un commentaire