How to add footer to NavigationView – Android support design library? –

Development issue/problem:

How do I adjust the basement settings and profile items in NavitationView to look like navigation data? The NavitationView items are blown up by the menu source, but I don’t know how to adjust the source items in the lower menu or how to set a custom view in the navigation view or a lower offset? I tried to display it as a footer, but on the small screens the footer is above the items and I can’t scroll through the menu. I tried to set the footer for the navigation display, but the footer also takes the plates.

No scrolling on small screens:

It scrolls, but the footer scrolls through the menu items :

Fileres/menu/drawer.xml from the drawer menu :

How can this problem be solved?

Decision No 1:

If you want a fixed (non-scrolling) footer in the navigation menu, you need to wrap NavigationView around a different layout than the one you have published. NavigationView works as FrameLayout, i.e. the internal layout is superimposed on the menu items in NavigationView. Here is a way to do this, using LinearLayout for the lower elements:

Fixed branch

In this example I used TextViews, but you can use anything you need to display your footers. To avoid overlapping footers at the bottom of the menu, add some dummy entries at the end of the source file of the menu (they act as spaces) :

res/menu/ tray.xml

And last but not least, don’t forget to add click listeners to your activity to really show off your footers:


// Press on the handset to go to the footer.
NavFooter1 view = findViewById(R.id.footer_item_1);navFooter1.setOnClickListener(new view).OnClickListener() {@Crossing public space onClick(view v) {// Perform footer action});view navFooter2 = findViewById(R.id.footer_item_2);navFooter2.setOnClickListener(new view.OnClickListener()). {@Click onCrossing public blank(view v) {// Perform footer action} ) .

Swivel foot

However, if you let your footer scroll with the rest of NavigationView, it becomes easier (no extra layouts or clicks from the listeners). Simply add footers to the menu source file as unique (this creates a cut-off line) and everything is automatically processed and scrolled together:

res/menu/ tray.xml

Decision No 2:

I’m just giving you a hint on how to solve the problem, but I don’t have a way to test it with NavigationView and I’m sure it will work.

Here is an example for the xml layout;

Here’s the result:

The trick is to put a pillow over the baby and a negative field over the baby.

Quick test:

Decision No 3:

After the approaches described in other answers to the questions on nest navigation, there were some problems:

  • If there are multiple entries or in landscape format, the footer is placed over the menu items.
  • If there are a lot of items in the real menu, the nested navigation view got a scroll that wasn’t nice to see.
  • With two navigation views in the lock, it was not possible to define custom views as footers.
  • Dealing with nested scrolls was chaotic (sometimes two scrolls appeared, etc.).
  • The foothold must always be at the bottom (for many and varied menu items).

My solution to all these problems was this:

Here NestedScrollView acts as a scroll holder for the NestedScrollView subNavigationView.
This means that SubNavigationView itself never displays scrollbars, but all content is displayed flat.

The space_in_bottom layout fills the rest of the space, so that for some menu icons the footer remains at the bottom.

Finally, a fixed footer is added to a line graph that starts with a real menu (subNavigationView), a spacer and a footer at the bottom.

Here you can find an example of the complete work as an AndroidStudio project: https://github.com/MarcDahlem/AndroidSidemenuFooterExample.

The navigation box can be found here:
https://github.com/MarcDahlem/AndroidSidemenuFooterExample/blob/master/app/src/main/res/layout/activity_main.xml.

Screenshots:

Decision No 4:

The easiest answer is to add a button in the tray diagram and set its severity at the bottom of the navigation image window.xml.

Here’s the code:

Decision No 5:

You need a layout of the navigation type Container, which must then contain two additional navigation types. List them at the top and bottom of the parents’ presentation.

I recommend using the navigation view as the parent element and not as FrameLayout, because it is actually ScrimFrameLayout and it interacts better with the status bar.

Here is an example of what your company should look like:

You can read more here and see an example: http://blog.nitish.io/post/122633295558/android-design-library-navigationview-with-top.

Decision No 6:

I know his late answer, but his perfect and precise answer that most developers are looking for.

To add a footer to the navigation view, add a custom view to the navigation menu as shown below

footer_navigation_menu.xml

Now add a top view to the xml menu with the attribute group, so you can distinguish them at the bottom of the menu.

profile_menu.xml

Here we go. Below you can see the result:

Decision No 7:

It is a pity that NavigationView does not offer the possibility to add a footer. But you can try something like that,

If your footer is a list,

app:headerLayout=@null
app:menu=@menu/activity_base_drawer_footer

But if this is some kind of custom display,

app:headerLayout=@layout/my_cutom_footer_view
app:menu=@null

In this case, you also need to set x = height of your custom header display.

I hope this helps.

Decision No 8:

. I did the same thing I did here:

The important thing is that I put the gravity locus down, for example.

LinearLayout android: layout_gravity=bottom

Decision No 9:

So I add the page layout at the bottom of the navigation:

Updated libraries

Decision No 10:

If you follow your approach, some small changes can contribute to what you want to achieve.

And set some connectors in the menu so the menu items don’t overlap.

You also want to add a click listener to your footer.

Good luck!

Related Tags:

best basic keyboard,best keyboard for writers,razer pro type,laptop style keyboard,best keyboard for gaming,corsair k83 wireless entertainment keyboard,best keyboard for writers reddit,best keyboards for essays,journalist keyboard,best non mechanical keyboard reddit,best laptop keyboard for writers,logitech k800 illuminated wireless keyboard.,best mechanical keyboard for typing,best mechanical keyboard for gaming,corsair k95 platinum xt,best mechanical keyboards reddit,clicky keyboards,wasd code v3,best keyboard for designers 2020,best office keyboard and mouse,laptop external keyboard,das keyboard prime,best programming keyboard 2020,kinesis advantage2 ergonomic keyboard,best keyboards for programming reddit,best mouse for programming,filco ninja majestouch-2,kinesis freestyle edge rgb,keyboards for architecture,the most popular design of keyboard is,the caps lock key is also called,the caps lock key is called,anker universal bluetooth wireless keyboard,belkin mobile wireless keyboard,writer's key,wired lighted keyboard,best mechanical keyboard,best compact keyboard,best keyboards for typing,best gaming keyboard,best wireless mechanical keyboard,best chiclet keyboard