Overlay ActionBar with sliding drawer - android

Is it possible to overlay the actionbar with one specific view(i.e sliding drawer)? I know i can make the whole activity full screen and put the action bar on top of it, but i need to slide a sliding drawer on top of the action bar.

You can now layout the action bar as a "toolbar" which behaves in the layout just as any other view, and then you can overlay other views (Using frame layouts, drawer layouts etc).
See the section in here about toolbar:
http://android-developers.blogspot.com/2014/10/appcompat-v21-material-design-for-pre.html
As Toolbar is just a ViewGroup, you can style and position it however you want.
Then in your Activity or Fragment, set the Toolbar to act as your Action Bar:

Related

Coordinator layout "layout_behavior" hide bottom navigation bar on all bottom tabs

I used Coordinator layout and app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior" on Bottom Navigation Bar.
This works fine for auto hiding Bottom Navigation bar but
I don't want to hide my Bottom navigation bar for all tabs, I want to hide it for selected tab like Home and Menu other tabs scrolling should not hide bottom navigation bar.
Is there any way to implement this with Coordinator layout?
The scroll flag used within the attribute app:layout_scrollFlags must be enabled for any scroll effects to take into effect. This flag must be enabled along with enterAlways, enterAlwaysCollapsed, exitUntilCollapsed, or snap
Coordinate Layout

How to pairing bottom app bar with top app bar?

In the picture what I want to do.
I have two menu.xml files. How to add the first menu at top app bar and the second at the bottom app bar? Can I do this in one activity or I should create activity with top app bar + fragment with a bottom app bar? Thanks.
So, I solved this problem.
For toolbar on top of the activity I use setSupportActionBar() inflate menu in onCreateOptionsMenu() and processing MenuItem click in onOptionsItemSelected()
For BottomAppBar (new material component) I use bottomAppBar.replaceMenu() in order to set the menu. For processing MenuItem click: bottomAppBar.setOnMenuItemClickListener()
Result
How to add the first menu at top app bar and the second at bottom app
bar? Can I do this in one acivity or I should create Activity with top
app bar + fragment with bottom ap bar?
You'll probably be able to do that with onCreateOptionsMenu() for the top of the Activity, (called Toolbar) then use a NavigationDrawer and another View (Can be a custom view like LinearLayout with ImageViews or etc) or another Toolbar in the bottom.
Or, using custom view and inflating menus by onCreateOptionsMenu().
This might help for two Toolbars in one Activity: https://stackoverflow.com/a/37002188/4409113
Also: https://stackoverflow.com/a/34906999/4409113
In your case (as we can see in the picture), i believe there is a Toolbar at top of Activity, with CoordinatorLayout which has FloatingActionButton in the middle and there will be just inflating in java-kotlin side left.

How to hide a certain activity's action bar while maintaining the navigation bar?

I'm developing an application with a side navigation menu.
In my activities, the action bar of the activity I'm loading overlays the action bar with the side navigation menu. Even though the side menu is there and works fine.
Home page with the side navigation:
Side navigation works when swiping:
I want to hide or remove the activity's action bar while maintaining the side navigation menu.
This is the code from the onCreate() method
FrameLayout contentFrameLayout = (FrameLayout) findViewById(R.id.content_frame);
getLayoutInflater().inflate(R.layout.activity_complaint, contentFrameLayout);
you can do 2 things
you can provide padding to the side navigation menu , so that the side navigation menu will be displayed just below the action bar
another thing you can do is to hide the Action bar when Navigation Drawer icon is clicked
the code to hide Action bar is below
android.support.v7.app.ActionBar AB= getSupportActionBar();
AB.hide();
I found a solution using the answer from this question:
How to Display Navigation Drawer in all activities?
and adding this bit of code to my activity in the Manifest.xml file
android:theme="#style/AppTheme.NoActionBar"

Frame Layout for navigation drawer activity

I am implementing Navigation Drawer in my Main Activity. When I load a fragment for the drawer item, the action bar gets overlapped above the fragment.I am required to give a top margin of about 48 dp, so that my views come below the action bar. How can I bring my fragment layout below the ActionBar?
layout_marginTop="?attr/actionBarSize"
use this in your layout it changes in size based on screen configuration automatically
Have a look at this tutorial:
android-sidebar-navigation-drawer-with-icons

Android: Is it possible to hide the top part of the actionbar but keep the bottom bar with the overflow buttons

currently i am using ActionbarSherlock.
Right now, my apps has a Bar at top and a bar at the bottom with overflowed buttons.
I want a custom header bar and do not want to try to theme the Actionbar header bar, but I want to keep the bottom bar with the buttons.
Is it possible to hide the Header bar portion of the ActionBar?
ActionBar().hide() hides both top and bottom bars.
According to the action bar doc ("Using split action bar"): add uiOptions="splitActionBarWhenNarrow" to the corresponding manifest element. Then use setDisplayShowHomeEnabled(false) and setDisplayShowTitleEnabled(false). The tabs move are moved into the - now empty - top bar.

Categories

Resources