Set Margins programmatically for Navigationview support design library - android

I have implemented Navigation Drawer using NavigationView from design support library. I want to change the margins of nav drawer depending on the nav menu item selected. Basically I want that NavDrawer should always be below the toolbar and tabs, if present.
I tried below code to set the top margin but it doesn't work. No APP crash but drawer doesn't open when I click hamburger icon. Pls help SO community.
DrawerLayout.LayoutParams params = (DrawerLayout.LayoutParams)mNavigationView.getLayoutParams();
params.setMargins(0,72,0,0);
mNavigationView.setLayoutParams(params);

Related

how to put a profile image and a searchbar in a toolbar?

I am new to Android development I am building an app but from last three days, I am stuck while making toolbar I am very confused. I want to make toolbar like this
The widget elements in your design are the following from left to right:
Navigation Drawer Indicator
ImageView
SearchView
Toggle
Overflow Menu
These can all be implemented using default widgets. It is not common to put a profile image to the right of the title, but you could do this by putting a custom layout inside the toolbar view.
It is also not common to place a toggle in the action bar, but it is possible using an ActionLayout.

Android Navigation drawer menu item icon color

I need to know how to set specific color for each menu item icon in navigation drawer.I am currently using latest navigation drawer in android studio 1.4.1 and also how can we include navigation header image view and name in our activity since the navigation header is in separate layout.
Include two navigation drawers in you layout file and assign gravity left for one and gravity right for another either dynamically or programmatically

Android design support navigation drawer align on bottom

How can I align a part of the items in the navigation drawer (like settings and help) to the bottom of the navigation drawer like the google apps do? Is that supported in the new design support navigation drawer?
Those are ListView's footer views, which are always drawn after every other list item.
listView.addFooterView(inflater.inflate(R.layout.footer, null));

Making ActionBar tabs appear under the content AND integrate a WebView in an ActionBar Menu

I'm currently working on an Android application with two ActionBar Tabs.
I have three questions:
1) How can I make the ActionBar Tabs to appear on the bottom of the app (under the fragments)
2) Can I make a WebView in a Navigation drawer (menu)
3) How can I let the ActionBar menu appear on the right side of the ActionBar?
Thanks for answering
EDIT:
With an ActionBar menu, I'm meaning the menu on the middle of this Picture:
http://static.androidnext.de/Facebook-for-Android.jpg
How can I make the ActionBar Tabs to appear on the bottom of the app (under the fragments)
Sorry, that is not possible with action bar tabs. You cannot even control if they show up as tabs at all, let alone their position.
Can I make a WebView in an ActionBar Menu (the menu for example Facebook has the main Navigation)
What you are referring to is a navigation drawer. Putting a WebView in a navigation drawer is technically possible but is unlikely to meet Google's design guidelines for navigation. In your case, given your third question, you presumably are not using this for navigation.
How can I let the ActionBar menu appear on the right side of the ActionBar?
That depends on what you are using for the navigation drawer. DrawerLayout supports this:
Drawer positioning and layout is controlled using the android:layout_gravity attribute on child views corresponding to which side of the view you want the drawer to emerge from: left or right. (Or start/end on platform versions that support layout direction.)

Navigation Drawer Problems

in my android project, I have set up a navigation drawer. Now, on swiping, the drawer works fine but I have a few problems that I'd liked solved.
There is no drawer icon to the left side of my launcher icon in the action bar. How do you implement that. Also when I click on the action bar icon, the navigation drawer does not slide in.
I would like to change the color of the text of my ListView inside my navigation drawer. I tried changing android:textColor in the xml layout but it didn't work.
I have the drawer_shadow.9.png drawable of the navigation drawer and I tried implementing it using the setDrawerShadow(drawable, gravity); method but it didn't seem to work. In the two parameters I added the drawable and the ListView R.id for the gravity.
That's just about it. Let me know if you need any more info. Thanks in advance.
There is no drawer icon to the left side of my launcher icon in the action bar. How do you implement that. Also when I click on the action bar icon, the navigation drawer does not slide in.
Use ActionBarDrawerToggle.
I would like to change the color of the text of my ListView inside my navigation drawer. I tried changing android:textColor in the xml layout but it didn't work.
If the "xml layout" is the one for the row, it should work. If the "xml layout" is the one for the drawer (where your ListView is), it should not work.
In the two parameters I added the drawable and the ListView R.id for the gravity.
From elsewhere in the DrawerLayout documentation, I think your interpretation of the second parameter is off:
Gravity.LEFT to move the left drawer or Gravity.RIGHT for the right. GravityCompat.START or GravityCompat.END may also be used.

Categories

Resources