This works for me. Just use the old deprecated way in the else clause: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { getWindow().setDecorFitsSystemWindows(false); WindowInsetsController controller = getWindow().getInsetsController(); if(controller != null) { controller.hide(WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars()); controller.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); } }
@@UltimaX9578 It works great when you did that only once, but in reality, we have to create our own abstraction function that handle both old and new Android without duplicating same expression over and over. Sadly, Android SDK never help us on this problem
@@KangJangkrik Correct, I only showed the relevant part. I use this function and it can be placed anywhere (tuck it away in a singleton / utility class, keep it in the main activity, etc.). I just have it in my main activity since that's the only place I use it. Also, this has been tested on a commercial product for API 19+. Just call it in the main activity's onCreate function: private void initSystemUiVisibility() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { getWindow().setDecorFitsSystemWindows(false); WindowInsetsController controller = getWindow().getInsetsController(); if(controller != null) { controller.hide(WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars()); controller.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); } } else { final int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; getWindow().getDecorView().setSystemUiVisibility(flags); getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(visibility -> { if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) { getWindow().getDecorView().setSystemUiVisibility(flags); } }); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } }
I have a bug, i am try to do collapsing AND expanded header + nested scroll view. In my case header image should expand follow drag down on nested scroll view, collapsing works perfectly, but drag down not working like ignored, if i use linearlayout instead of nested scroll all works perfectly both scenes "collapse" and "expand" works together dragging by one linearlayout
surfaceview is rendered at hardware level, rotation is applied at different portion in the graphics pipeline, so it cannot rotate the content. instead you must rotate the content of the surfaceview canvas via a transformation matrix. you should be able to hook the rotation property of the view class.
Is there any way to see source code of examples showed in video?
Does this work efficiently for lower API levels as well? Can animation like this cause frame drops and janky UI?
Looks very difficult to understand after first episodes and even after trying codelab
I'm not even sure if I should go into the long learning of MotionLayout, judging that Compose is in the making
why there's no github link😠
4:11 we all saw the deprecated code for going edge to edge. Sad that this is not straightforward to do either.
"Android architecture are made while drunk"
- people at reddit
This works for me. Just use the old deprecated way in the else clause:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
getWindow().setDecorFitsSystemWindows(false);
WindowInsetsController controller = getWindow().getInsetsController();
if(controller != null) {
controller.hide(WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars());
controller.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
}
}
@@UltimaX9578 It works great when you did that only once, but in reality, we have to create our own abstraction function that handle both old and new Android without duplicating same expression over and over. Sadly, Android SDK never help us on this problem
@@KangJangkrik Correct, I only showed the relevant part. I use this function and it can be placed anywhere (tuck it away in a singleton / utility class, keep it in the main activity, etc.). I just have it in my main activity since that's the only place I use it. Also, this has been tested on a commercial product for API 19+. Just call it in the main activity's onCreate function:
private void initSystemUiVisibility() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
getWindow().setDecorFitsSystemWindows(false);
WindowInsetsController controller = getWindow().getInsetsController();
if(controller != null) {
controller.hide(WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars());
controller.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
}
} else {
final int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_FULLSCREEN |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
getWindow().getDecorView().setSystemUiVisibility(flags);
getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(visibility -> {
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
getWindow().getDecorView().setSystemUiVisibility(flags);
}
});
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN |
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
}
@@UltimaX9578 Ah man, the fact that we even need to do all this, and handle flags individually hurts me.
Why there is no video of how it will look in actual app
*Motion Layout Integrations samples*
github.com/android/views-widgets-samples/tree/main/ConstraintLayoutExamples/motionlayoutintegrations
Is it possible to find the code somewhere?
I look forward to know how to work with this
I have a bug, i am try to do collapsing AND expanded header + nested scroll view. In my case header image should expand follow drag down on nested scroll view, collapsing works perfectly, but drag down not working like ignored, if i use linearlayout instead of nested scroll all works perfectly both scenes "collapse" and "expand" works together dragging by one linearlayout
Why can't I rotate a surfaceview, even if I setted the rotation field?
surfaceview is rendered at hardware level, rotation is applied at different portion in the graphics pipeline, so it cannot rotate the content. instead you must rotate the content of the surfaceview canvas via a transformation matrix. you should be able to hook the rotation property of the view class.
Not easy to follow with the design editor view instead of the XML view. Too bad the source code is not made available...
:s dont you think its too complex?
Nice
So ~~~~ cool! 👍😆
But... Does it work?
Lol I will give it a shot let's see how it behaves :D
OK.
👍
❤️❤️
Nice