自定义dialog 让它覆盖到statusbar

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Rodulf/article/details/86533226

    public void click2(View view) {


        MyDialog alertDialog  = new MyDialog(this,R.style.AppThemeDialogFull);
        alertDialog.setTitle("test4");
        alertDialog.setContentView(R.layout.activity_text);
        alertDialog.show();

    }
<style name="AppThemeDialogFull" parent="ThemeOverlay.AppCompat.Dialog.Alert">
        <!-- Customize your theme here. -->
        <item name="android:backgroundDimAmount">0.5</item>
        <item name="android:backgroundDimEnabled">false</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:layout_gravity">bottom</item>
        <item name="android:windowBackground">@mipmap/background_1</item>
    </style>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="690dp"
    android:orientation="vertical">

    <Button
        android:layout_width="match_parent"
        android:layout_height="20dp"
        android:text="click1"/>

</LinearLayout>
package bjpkten.systemuiflagtest;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.Gravity;
import android.view.ViewGroup;
import android.view.WindowManager;

/**
 * Created by Kodulf on 2019/1/15.
 */
public class MyDialog extends Dialog {

    public MyDialog( Context context) {
        super(context);

//        getWindow().requestFeature(Window.FEATURE_NO_TITLE);
//        getWindow().setDimAmount(0.5f);

//        getWindow().setBackgroundDrawable(R.mipmap.background_1);


    }

    public MyDialog( Context context, int themeResId) {
        super(context, themeResId);


    }

    protected MyDialog( Context context, boolean cancelable,  DialogInterface.OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }


    @Override
    public void show() {
//        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
//        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

//        getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
//        getWindow().getDecorView().setPadding(0,0,0,0);

//        WindowManager.LayoutParams attributes = getWindow().getAttributes();
//        attributes.width= 1000;
//        attributes.height = 2800;

//        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
        super.show();

        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT,1820);
        getWindow().setGravity(Gravity.BOTTOM);
//        getWindow().setGravity(Gravity.TOP);
//        getWindow().getDecorView().setPadding(0,0,0,0);
//        getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN|WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS|WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);


//        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//        getWindow().setNavigationBarColor(Color.parseColor("#474747"));
//        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
//        this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
//        getWindow().getDecorView().setPadding(300,300,300,300);
//        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
//        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
//        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

    }
}

猜你喜欢

转载自blog.csdn.net/Rodulf/article/details/86533226