I am trying to reproduce the behaviour of Google Calendar application:
but I have not found a way to change the status text color. If i set the colorPrimaryDark as whit
As previous, the SYSTEM_UI_FLAG_LIGHT_STATUS_BAR do the work in my case, don't forget to set for higher than API 22.
add this to oncreate after the setContentView:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
Try this once.
In your activity onCreate()
method, paste the following code.
try {
if (android.os.Build.VERSION.SDK_INT >= 21) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(ContextCompat.getColor(this, R.color.color_red));
}
} catch (Exception e) {
e.printStackTrace();
}
Note: color_red - is the status bar colour.
you can do that programmatically like this answer
just add this
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);// set status text dark
getWindow().setStatusBarColor(ContextCompat.getColor(MainActivity.this,R.color.colorPrimaryDark));// set status background white
It works for me
In your activity onCreate()
method, paste the following code after the setContentView(R.layout.activity_generic_main);
Here is the sample code below.
public class GenericMain extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_generic_main);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
}
Try this if not splash page
getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
getActivity().getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
getActivity().getWindow().setNavigationBarColor(ContextCompat.getColor(context, R.color.white));
getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(context, R.color.white));