drawerlayout

Change Navigation View Item Color Dynamically Android

こ雲淡風輕ζ 提交于 2019-11-27 13:17:17
I'd like to build a navigation drawer where each item has a different selection color (the icon tint and text color) as the google play store has: I'm not sure how they've solved this, I think they use different activities with different drawers. I want to use fragments and I want to change the icon tint and text color. Any ideas how I can do this? I'm using google's design support library and a drawer layout with a navigation view in there. use app:itemIconTint in your NavigationView for icons and use app:itemTextColor for textColors Sample : drawable/navigation_text_color : <selector xmlns

ClassCastException android.widget.FrameLayout$LayoutParams to android.support.v4.widget.DrawerLayout$LayoutParams

五迷三道 提交于 2019-11-27 12:35:32
I'm working on the Navigation Drawer for Android. As per my requirement I was to display gridview and listview of items in the navigation drawer. I have created a linearLayout in the layout xml file and placed the two widgets(Grid view, and Listview) in the LinearLayout. When I run the file I'm getting the following error: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.navigationdrawer3/com.example.navigationdrawer3.MainActivity}: java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to android.support.v4.widget.DrawerLayout

How to detect that the DrawerLayout started opening?

£可爱£侵袭症+ 提交于 2019-11-27 12:01:02
So I have tabs that I want to hide when the Navigation Drawer starts opening. The code I have hides them when it finished opening, but it's not what I want. mDrawerToggle = new ActionBarDrawerToggle( this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close ) { @Override public void onDrawerClosed(View view) { invalidateOptionsMenu(); setActionBarMode(ActionBar.NAVIGATION_MODE_TABS); } @Override public void onDrawerOpened(View drawerView) { invalidateOptionsMenu(); setActionBarMode(ActionBar.NAVIGATION_MODE_STANDARD); } }; mDrawerLayout.setDrawerListener

How animate Burger to Arrow with Appcompat v7 21, Toolbar and DrawerLayout

折月煮酒 提交于 2019-11-27 11:34:22
I am using the android.support.v7.widget.Toolbar with a android.support.v4.widget.DrawerLayout. It works fine, the Burger icon is shown when the Navigation Drawer is closed, and the Arrow icon is shown when the Drawer is open. I want to disable the drawer and animate the Burger icon into Arrow on some event in the app. I have tried to set the lock mode to closed, but the v7.app.ActionBarDrawerToggle is still showing the Burger and it opens the Drawer. mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); Any ideas? Thanks! Update: No I can change the state of the icon and I

How to open Navigation Drawer with no actionbar, open with just a button

百般思念 提交于 2019-11-27 11:07:34
I have a navigation bar without any actionbar (I don't want an actionbar). I'm trying to make it so that I have a button that can open the navigation drawer. I know there's a method called openDrawer for the DrawerLayout http://developer.android.com/reference/android/support/v4/widget/DrawerLayout.html#openDrawer(android.view.View) I didn't know how to use it, but i have tried making a button when click, runs this method: DrawerLayout mDrawerLayout = (DrawerLayout) getView().findViewById(R.id.drawer_layout); mDrawerLayout.openDrawer(mDrawerLayout); When i click it on it, it gives me a Java

Is it possible to use something other than a listview as sliding drawer in drawerlayout

跟風遠走 提交于 2019-11-27 10:00:06
问题 I would like to have for example a LinearLayout or a RelativeLayout sliding from the left of the screen instead of a lone ListView . I tried to use à LinearLayout with android:layout_gravity="start" and i had this error at runtime: ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.support.v4.widget.DrawerLayout$LayoutParams here's the layout file: <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id=

Wrong size and click behavior for Views in DrawerLayout

天涯浪子 提交于 2019-11-27 08:28:47
问题 I have a layout for an Activity that I'm trying to add a navigation drawer to. The problem is, to work properly, I need to use: <android.support.v4.widget.DrawerLayout instead of: <RelativeLayout but it messes things up. My ProgressBar becomes much bigger, my RecyclerView doesn't work, the app logs me out when I click something, etc. My layout XML: <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns

How to implement a DrawerLayout with a visible handle

左心房为你撑大大i 提交于 2019-11-27 04:15:36
问题 I have successfully implemented a NavigationDrawer for my application. My app displays a drawer that opens on the left of the screen. My problem is I need to add a button on the left. That button might be clicked or swiped to open the left drawer. That I can do. But the button is supposed to look like it's a part of the drawer that would overflow into the screen. That means the button should slide simultaneously as the drawer opens and closes. CLOSED STATE : OPENING STATE I tried adding the

DrawerLayout's item click - When is the right time to replace fragment?

为君一笑 提交于 2019-11-26 23:56:44
问题 I'm developing an application which uses the navigation drawer pattern (With DrawerLayout). Each click on a drawer's item, replaces the fragment in the main container. However, I'm not sure when is the right time to do the fragment transaction? When the drawer starts closing? Or after it is closed? In google's documentaion example, you can see that they are doing the transaction right after the item click, and then close the drawer. As a result, the drawer seems laggy and not smooth, and it

make main content area active in DrawerLayout

六眼飞鱼酱① 提交于 2019-11-26 23:18:12
问题 How to make active main content area, while drawer is open. Currently, if main content area is clicked, drawer will be closed then touch event will be dropped, I want to catch that touch event and pass it to main content area. 回答1: You need to create custom DrawerLayout and @overide onInterceptTouchEvent . Then you can create some method for registering drawer views (like setDrawerViewWithoutIntercepting ), for which will be possible to use (click) main content, when are open. You should call