I've tried on Nougat
and Oreo
. Both phones are stock android and both views are visible and on screen. I require these views for my sharedElementTransition
. This question has been asked before here but with no answer. This is happening to a lot of people and they discuss it here in the comments of Alex Lockwood's answer, but with no definite solution.
I am calling findViewById()
from my activity and have tried both
findViewById(android.R.id.statusBarBackground);
and
getWindow().getDecorView().findViewById(android.R.id.statusBarBackground);
I've called the findViewById()
after setContentView()
Possibly related, but unlike progressBar
, statusBar
and navigationBar
views do exist almost all the time.
Code:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
getWindow().setSharedElementEnterTransition(getTransitionSet());
getWindow().setSharedElementExitTransition(getTransitionSet());
getWindow().setSharedElementReturnTransition(getTransitionSet());
getWindow().setSharedElementReenterTransition(getTransitionSet());
ActivityCompat.postponeEnterTransition(this);
setEnterSharedElementCallback(mCallback);
}
setContentView(R.layout.summary_image_preview);
navigationBar = getWindow().getDecorView().findViewById(android.R.id.navigationBarBackground);
statusBar = getWindow().getDecorView().findViewById(android.R.id.statusBarBackground);
mToolbar = (Toolbar) findViewById(R.id.toolBar);
// etc...
}
Toolbar
is a normal view inside my content view and it works fine. but statusBar
and navigationBar are null