G
G
gamess4312021-04-16 00:35:35
Java
gamess431, 2021-04-16 00:35:35

How to hide AppBarLayout programmatically in android?

(Corrected code!) Hello people, tell me how to hide the AppBar or what is the correct name? (ActionBar) in general, it doesn't matter! In my project there is such an AppBarLayout, 6078ae03d096f013258046.jpegI try to hide it programmatically, but my code does not work out

if (bla bla bla){
                    AppBarLayout AppBarLayout = findViewById(R.id.appbar_layout);
                    AppBarLayout .setVisibility(View.GONE);
}else{
   AppBarLayout .setVisibility(View.VISABLE);
}

It leaves behind a white background, and if you pass android:visibility="gone" to the layout, it is completely removed. Question: how to remove this white background?
6078b22d7da1e764703920.jpeg
Or how is it properly hidden so that it does not leave behind a white background? And the layout stretched to full height!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis Zagaevsky, 2021-04-16
@zagayevskiy

Find the view that occupies this space and hide it in the same way as you do it now. This is probably the parent of the toolbar. You can see it with the Layout inspector.

A
artem, 2021-04-16
@arteqrt

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

Create activity in onCreate

G
gamess431, 2021-04-16
@gamess431

Is it generally possible to assign absolute positioning to AppBar?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question