Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

the status bar changes it's color to black inside fullscreen dialog fragment android

I'm using dialog fragment. The problem is that the status bar color is changed to black. How to change it to some other color? It's strange cause inside fragment, activity it works fine. Its only black inside DialogFragment

        @Override
            public void onStart() {
                super.onStart();    //super.onStart() is where dialog.show() is actually called on the underlying dialog, so we have to do it after this point
                Dialog d = getDialog();
                if (d != null) {

                    int width = ViewGroup.LayoutParams.MATCH_PARENT;
                    int height = ViewGroup.LayoutParams.MATCH_PARENT;
                    d.getWindow().setLayout(width, height);
                    d.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

                }
            }
     @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            final Dialog dialog = new Dialog(getActivity(), R.style.full_screen_dialog);
            return dialog;

}
like image 569
Jenya Kirmiza Avatar asked Jan 04 '17 16:01

Jenya Kirmiza


People also ask

How can I change the color of my status bar in Android?

Step 1: After opening the android studio and creating a new project with an empty activity. Step 2: Navigate to res/values/colors. xml, and add a color that you want to change for the status bar. Step 3: In your MainActivity, add this code in your onCreate method.

How do I make my dialog fragment full screen?

setTransition(FragmentTransaction. TRANSIT_FRAGMENT_OPEN); // To make it fullscreen, use the 'content' root view as the container // for the fragment, which is always the root view for the activity transaction. add(android. R.

How to change status bar color in Android Studio?

Step 1: After opening the android studio and creating a new project with an empty activity. Step 2: Navigate to res/values/colors.xml, and add a color that you want to change for the status bar. Step 3: In your MainActivity, add this code in your onCreate method. Don’t forget to replace your desired color with colorName .

How do I use flag_layout_in_screen with the status bar?

You can use FLAG_LAYOUT_IN_SCREEN to set your activity layout to use the same screen area that's available when you've enabled FLAG_FULLSCREEN. This prevents your content from resizing when the status bar hides and shows.

How do I hide the status bar on Android 4?

Hide the Status Bar on Android 4.0 and Lower. You can hide the status bar on Android 4.0 (API level 14) and lower by setting WindowManager flags. You can do this programmatically or by setting an activity theme in your app's manifest file.

How to make the condition bar dark in the appbarlayout?

Establish the status bar icon and condition bar text shade to dark. The sight design is listed below the obligation format to ensure that the view design does not obscure the condition bar impact. This is mostly by paying attention to the distance of the AppBarLayout moving, and also sliding upwards.


1 Answers

You have to set FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDSto indicate that this Window is responsible for drawing the background for the system bars.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        dialog.getWindow().setStatusBarColor(yourColor); 
    }
like image 87
ucMedia Avatar answered Sep 17 '22 20:09

ucMedia