Notification Bar is double drawed on Top Navigation Bar View Android - android

Hello guys I have problem with NavigationBarView. I set NavigationBarView this without not swipe and I set Other view above NavigationBarView. I made this Activity with Tranculents Style. But I have got error, the notification bar is double, this drawed on top NavigationBarView.
This my XML:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.ad.sample.ui.activity.HomeActivity">
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
</fragment>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/btn_main_menu"
android:layout_alignBottom="#+id/navigation_view"
android:background="#color/biru"
android:layout_alignParentTop="true"
android:clickable="true"
android:soundEffectsEnabled="false" />
<android.support.design.widget.NavigationView
android:paddingLeft="8dp"
android:id="#+id/navigation_view"
android:layout_below="#+id/btn_main_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/biru"
app:itemTextColor="#color/white"
app:menu="#menu/main_menu" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/btn_main_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="#dimen/marginTopToolbar"
app:backgroundTint="#color/white"
app:elevation="1dp" />
</RelativeLayout>
</FrameLayout>
And this Style-v21
<style name="AppTheme.HomeActivity">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
How to fix it?

Try this:- your code is working fine in mine case , looks like the problem of double notification bar is due to some other reason. But i have rectified your code.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.ad.sample.ui.activity.HomeActivity">
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
</fragment>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_above="#+id/btn_main_menu"
android:background="#color/blue"
android:clickable="true"
android:soundEffectsEnabled="false" />
<android.support.design.widget.NavigationView
android:paddingLeft="8dp"
android:id="#+id/navigation_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/blue"
app:itemTextColor="#color/white"
app:menu="#menu/main_menu"
android:layout_alignParentBottom="true"
/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/btn_main_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
app:backgroundTint="#color/white"
app:elevation="1dp"
android:layout_above="#+id/navigation_view"/>
</RelativeLayout>
</FrameLayout>

Related

Align custom view to left of navigation drawer

As you can see the custom layout is at the right and after some research I found that the blank space is reserved for icon and text of item. Is there a way to remove that blank space and align the custom layout to the left?
I am using menu to fill the navigation view as shown below:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<android.support.design.widget.NavigationView
android:id="#+id/nav1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="#layout/nav_header"
app:menu="#menu/nav_drawer_items"
app:itemBackground="#color/app_bg_color"
app:itemIconTint="#color/text_white"
app:itemTextColor="#color/text_white"
android:background="#color/bottom_navigation_color"
android:fitsSystemWindows="true"
android:theme="#style/NavigationView" />
</android.support.v4.widget.DrawerLayout>
nav_drawer_items
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="#+id/tabs"
android:title="MAIN">
<menu>
<item
android:id="#+id/nav_highlights"
android:icon="#drawable/icon_home"
android:title="#string/nav_home"
android:checkable="true"/>
<item
android:id="#+id/nav_movies"
android:icon="#drawable/icon_movie"
android:title="#string/nav_movies"
android:checkable="true"/>
<item
android:id="#+id/nav_originals"
android:icon="#drawable/icon_original"
android:title="#string/nav_originals"
android:checkable="true"/>
<item
android:id="#+id/nav_live_tv"
android:icon="#drawable/icon_live"
android:title="#string/nav_live_tv"
android:checkable="true"/>
</menu>
</item>
<item
android:id="#+id/support"
android:title="SUPPORT">
<menu>
<item
android:id="#+id/nav_about_us"
android:icon="#drawable/icon_about"
android:title="#string/nav_about_us"
android:checkable="true"/>
<item
android:id="#+id/nav_feedback"
android:icon="#drawable/icon_feedback"
android:title="#string/nav_feedback"
android:checkable="true"/>
<item
android:id="#+id/nav_setting"
android:icon="#drawable/icon_setting"
android:title="#string/nav_setting"
android:checkable="true"/>
<item
android:id="#+id/nav_logout"
android:icon="#drawable/icon_logout"
android:title="#string/nav_logout"
android:checkable="true"/>
</menu>
</item>
<item
android:id="#+id/connect_us"
android:title="Connect with us">
<menu>
<item
android:id="#+id/social_items"
android:checkable="true"
app:showAsAction="always"
android:title=""
app:actionLayout="#layout/connect_us"/>
</menu>
</item>
</menu>
In menu you can see that I am using a layout using app:actionLayout in last item. Here is the connect_us.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/app_bg_color"
android:orientation="horizontal"
android:gravity="start">
<ImageView
android:id="#+id/connect_youtube"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/youtube_icon"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:padding="5dp" />
<ImageView
android:id="#+id/connect_facebook"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/facebook_icon"
android:padding="5dp"/>
<ImageView
android:id="#+id/connect_twitter"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/twitter_icon"
android:padding="5dp"/>
</LinearLayout>
Change your code according to my , its working . Take RelativeLayout as parent (only change with your connect_us.xml):
connect_us.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#FFFFFF"
android:gravity="left">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/connect_youtube"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#mipmap/ic_launcher"
android:padding="5dp" />
<ImageView
android:id="#+id/connect_facebook"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#mipmap/ic_launcher"
android:padding="5dp"/>
<ImageView
android:id="#+id/connect_twitter"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#mipmap/ic_launcher"
android:padding="5dp"/>
</LinearLayout>
</RelativeLayout>
Second Solution :
In your main_activity.xml (fix the width of the Navigation drawer)
I used here
android.support.design.widget.NavigationView to android:layout_width="320dp" I know its not a proper solution to fix layout_width.
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="320dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main"
app:menu="#menu/activity_main_drawer"
/>
And connect_us.xml layout also set the layout_width = "320dp"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="320dp"
android:layout_height="match_parent"
android:background="#color/app_bg_color"
android:orientation="horizontal"
android:gravity="start">
<ImageView
android:id="#+id/connect_youtube"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/youtube_icon"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:padding="5dp" />
<ImageView
android:id="#+id/connect_facebook"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/facebook_icon"
android:padding="5dp"/>
<ImageView
android:id="#+id/connect_twitter"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/twitter_icon"
android:padding="5dp"/>
</LinearLayout>
Try adding your navigation view and Custom Layout (connect_us) inside a NestedScrollView as below:-
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.NavigationView
android:id="#+id/nav1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:background="#color/bottom_navigation_color"
android:fitsSystemWindows="true"
android:theme="#style/NavigationView"
app:headerLayout="#layout/nav_header"
app:itemBackground="#color/app_bg_color"
app:itemIconTint="#color/text_white"
app:itemTextColor="#color/text_white"
app:menu="#menu/nav_drawer_items" />
<include
android:id="#+id/footer_layout"
layout="#layout/connect_us"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.DrawerLayout>
Also, make sure to disable Nested Scrolling of NavigationView's child as below:-
ViewCompat.setNestedScrollingEnabled(navigationView.getChildAt(0), false);
I got a solution for this use recyclerview and inside your navigation view and add your views to recyclerview and create your adapter :
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="320dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="#+id/my"
layout="#layout/nav_header_main" />
<android.support.v7.widget.RecyclerView
android:id="#+id/rvNavMenu"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="10dp"
android:layout_weight="7"
android:overScrollMode="never" />
</LinearLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>

Navigation Drawer - Have only icons and very big

I have a nav drawer implemented in my activity. The audience for my app is the elderly and I want the icons to be very large and take up the whole drawer height.
I am looking to have the 4 icons evenly spaced out and to have no text just big icons. I have tried playing around with the tag:
<dimen name="design_navigation_icon_size" tools:override="true"></dimen>
but I have not been able to get it to work. The icons simply keep overlapping each other when they get too big near the top. The images always seem to be contained in the header layout.
Create custom view and layout for drawer
<android.support.design.widget.NavigationView
android:id="#+id/nav_view_left"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_left" />
nav_header_left.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#color/right_side_header_bg_color"
android:theme="#style/ThemeOverlay.AppCompat.Dark"
android:paddingTop="#dimen/fifty"
android:paddingRight="#dimen/twenty"
android:paddingLeft="#dimen/twenty"
android:orientation="vertical"
android:weightSum="4">
<TextView
android:id="#+id/add_txt"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="Gallery"
android:drawableLeft="#android:drawable/ic_menu_gallery"
android:layout_gravity="center"
android:gravity="center"
android:layout_weight="1"
/>
<TextView
android:id="#+id/gall_txt"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="Gallery"
android:drawableLeft="#android:drawable/ic_menu_gallery"
android:layout_gravity="center"
android:gravity="center"
android:layout_weight="1"
/>
<TextView
android:id="#+id/menu_add_txt"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="Gallery"
android:drawableLeft="#android:drawable/ic_menu_add"
android:layout_gravity="center"
android:gravity="center"
android:layout_weight="1"
/>
<TextView
android:id="#+id/media_txt"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:drawableLeft="#android:drawable/ic_media_rew"
android:gravity="center"
android:text="Gallery" />
</LinearLayout>
Use this code for navigationView:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start"
android:theme="#style/AppTheme">
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#android:color/white"
android:titleTextColor="#color/theme_color_dark"
style="#style/AppTheme"
android:theme="#style/AppTheme"/>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
<fragment
android:id="#+id/menu_fragement"
android:tag="Menu"
android:layout_width="250dp"
android:layout_gravity="start"
android:name="com.app.medcallz.fragments.MenuFragement"
android:layout_height="match_parent"
/>
</android.support.v4.widget.DrawerLayout>
MenuFragment:
<LinearLayout
android:id="#+id/options_container"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_below="#+id/user_detail_container">
<ImageView
android:id="#+id/notificationsIcon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/nav_notificatios"
android:layout_weight="0.1"/>
<View
android:id="#+id/account_divider"
android:layout_width="fill_parent"
android:layout_height="#dimen/login_divider_width"
android:background="#color/white_color"
android:visibility="visible"
/>
</LinearLayout>

Android set full width on custom layouts for menu

I'm trying to attach custom layout for menu items on DrawerLayout, but as you see menu items don't have full width and i can't resolve this problem
My menu layout
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<group android:id="#+id/groupOne">
<item
android:id="#+id/inbox"
app:actionLayout="#layout/create_new"/>
</group>
</menu>
and my custom layout for that as create_new
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingTop="5dp"
android:paddingBottom="5dp">
<TextView
android:layout_width="match_parent"
android:layout_height="25dp"
android:text="New Text"
android:gravity="left|center"
android:layout_marginLeft="20dp"
android:background="#000"
android:textColor="#fff"/>
</LinearLayout>
Yeah, the only way that worked for me was to set android:layout_width="100000dp" on the custom layout's root view.
Ugly ugly hack, however.
Add custom Spinner in Navigation menu / Navigation drawer / menu item.
1) Create Menu Item in menu directory.
<menu>
> <item
> android:id="#+id/navigation_drawer_item3"
> app:actionLayout="#layout/nav_drawer_home_spinner"
> tools:ignore="MenuTitle,icon" />
</menu>
2)Navigation drawer where you can put all types of navigation drawer
here.
- header
-menu with icon
-menu without icon
-custom menu item (Spineer)
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="#color/md_white_1000"
tools:openDrawer="start">
<include
layout="#layout/app_bar_dashboard"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="#+id/navigation_drawer_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="0dp"
android:background="#color/md_white_1000"
android:nestedScrollingEnabled="true"
android:layout_gravity="start">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="vertical"
android:background="#color/md_white_1000">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/md_white_1000">
<android.support.design.widget.NavigationView
android:id="#+id/navigation_drawer_with_icon"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_gravity="center"
android:elevation="0dp"
android:background="#color/md_white_1000"
app:itemTextColor="#color/colorAccent"
app:itemIconTint="#color/colorAccent"
app:headerLayout="#layout/nav_header_dashboard"
android:theme="#style/NavigationViewStyle"
app:menu="#menu/activity_dashboard_drawer"/>
<android.support.design.widget.NavigationView
android:id="#+id/navigation_drawer_without_icon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/md_white_1000"
app:itemTextColor="#color/colorAccent"
android:elevation="0dp"
android:layout_gravity="bottom"
android:theme="#style/NavigationViewStyleOnlyText"
app:menu="#menu/activity_dashboard_withouticon_drawer"/>
<android.support.design.widget.NavigationView
android:id="#+id/navigation_drawer_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="0dp"
android:layout_gravity="bottom"
app:menu="#menu/activity_dashboard_spinner"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
3) Custom row_spinner_layout for putting your custom layout for menu
item of that navigation view.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1"
android:orientation="horizontal">
<ImageView
android:id="#+id/img_profilPic"
android:layout_width="0dp"
android:layout_weight="0.15"
android:layout_height="wrap_content"
android:padding="3dp"
android:src="#drawable/profilepic" />
     
<LinearLayout
android:layout_width="0dp"
android:layout_weight="0.7"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dp"
android:orientation="vertical">
<TextView
android:id="#+id/tv_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="#color/colorAccent"
android:text=""/>
<TextView
android:id="#+id/tv_subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textColor="#color/colorAccent"
android:text=""/>
</LinearLayout>
</LinearLayout>

how to create an expandable listView inside navigation drawer?

I need to create a navigation drawer like flipkart or Astro file manager app.
How can I replace a listView with an expandable listView?
I need an navigation Drawer like this:
This is my xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
tools:context=".MainActivity">
<include
layout="#layout/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!-- This DrawerLayout has two children at the root -->
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- This LinearLayout represents the contents of the screen -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- The main content view where fragments are loaded -->
<FrameLayout
android:id="#+id/flContent"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<!-- The navigation drawer that comes from the left -->
<!-- Note that `android:layout_gravity` needs to be set to 'start' -->
<android.support.design.widget.NavigationView
android:id="#+id/nvView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#android:color/white"
app:headerLayout="#layout/nav_header"
android:choiceMode="singleChoice"
app:menu="#menu/drawer_view" />
</android.support.v4.widget.DrawerLayout>
You can create an ExpandableListView and use it as your NavigationView. An example of xml result:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
tools:context=".MainActivity">
<include
layout="#layout/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!-- This DrawerLayout has two children at the root -->
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- This LinearLayout represents the contents of the screen -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- The main content view where fragments are loaded -->
<FrameLayout
android:id="#+id/flContent"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<!-- The navigation drawer that comes from the left -->
<!-- Note that `android:layout_gravity` needs to be set to 'start' -->
<ExpandableListView
android:id="#+id/lvExp"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_gravity="start"/>
</android.support.v4.widget.DrawerLayout>
You can find an example of using an ExpandableListView here
You must make an ExpandableListView in your NavigationDrawer
you please follow throw these links and apply
How to create drawer navigation like this?
and
list and expandable list in single drawer
hope this will help you
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main"
app:itemIconTint="#color/colorPrimary"
app:itemTextAppearance="#style/TextAppearance.AppCompat.Body2">
<ExpandableListView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/navigationmenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="41dp"
android:layout_marginTop="90dp"
android:background="#android:color/white"
android:choiceMode="singleChoice"
android:dividerHeight="1dp"
android:groupIndicator="#null"
android:listSelector="#color/colorAccent" />
<Button
android:id="#+id/session_logout"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_gravity="bottom"
android:background="#color/colorPrimary"
android:text="Logout"
android:textColor="#fff" />
</android.support.design.widget.NavigationView>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="52dp"
android:background="#color/themeColor"
android:padding="10dp">
<ImageView
android:id="#+id/home"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:background="#drawable/menu_icon" />
<TextView
android:id="#+id/appname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/home"
android:gravity="left|center_vertical"
android:text="Home"
android:textColor="#FFFFFF"
android:textSize="20dp" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical|right"
android:src="#android:drawable/ic_menu_share" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:src="#drawable/setting"
android:visibility="gone" />
</RelativeLayout>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<!-- Drawer Content -->
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp" />
<!-- The navigation menu -->
<LinearLayout
android:id="#+id/header"
android:layout_width="260dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="#color/colorDrawer"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="top"
android:paddingLeft="50dp"
android:paddingRight="50dp"
android:paddingTop="5dp"
android:src="#drawable/logo" />
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/colorDrawerText" />
<ExpandableListView
android:id="#+id/lvExp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:background="#color/colorDrawer"
android:choiceMode="singleChoice"
android:groupIndicator="#android:color/transparent"
android:listSelector="#color/themeColor"></ExpandableListView>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
<!--android:groupIndicator="#null"-->
This is done going through the androihive.com tutorial - "ExpandableListView example" =============Link for your reference is http://www.androidhive.info/2013/07/android-expandable-list-view-tutorial/
Vinod Kumar Gaur

Compatiblity on NavigationView and Toolbar in Kitkat

i'm trying to run the project and its really cool in Lollipop devices(designs and etc.without any problem)
But there is a problem in this project and i havent any experiences about this compatiblity in Kitkat.after installing:
http://i.imgur.com/KSYkyeu.png
I'm using : https://github.com/AkashBang/NavigationView
and here is the activty main:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:custom="http://schemas.android.com/tools"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/v"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="1">
<include
android:id="#+id/toolbar"
layout="#layout/tool_bar">
</include>
<com.daimajia.slider.library.SliderLayout
android:id="#+id/slider"
android:layout_width="match_parent"
android:layout_height="175dp"
android:elevation="2dp"
custom:auto_cycle="true"
custom:indicator_visibility="invisible"
custom:pager_animation="Accordion"
custom:pager_animation_span="1000" />
<Button
android:id="#+id/btncat"
android:layout_width="300dp"
android:layout_height="55dp"
android:layout_gravity="center"
android:drawableStart="#drawable/ic_home"
android:paddingEnd="40dp"
android:paddingStart="20sp"
android:text="#string/category"
android:textColor="#FFFFFF"
android:textDirection="ltr" />
<android.support.v7.widget.CardView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="9dp"
android:layout_marginRight="9dp"
android:layout_marginTop="1dp"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="3sp"
card_view:cardUseCompatPadding="true">
</android.support.v7.widget.CardView>
<RelativeLayout
android:id="#+id/top_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignStart="#+id/cardview1"
android:layout_marginTop="30dp"
android:text="#string/rcrechome"
android:textAppearance="?android:attr/textAppearanceLarge" />
<android.support.v7.widget.CardView
android:id="#+id/cardview1"
android:layout_width="120dp"
android:layout_height="180dp"
android:layout_below="#+id/textView"
android:layout_marginEnd="9dp"
android:layout_marginStart="7dp"
android:layout_marginTop="20dp"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="3sp"
card_view:cardUseCompatPadding="true" />
<android.support.v7.widget.CardView
android:id="#+id/cardview2"
android:layout_width="120dp"
android:layout_height="180dp"
android:layout_alignTop="#+id/cardview1"
android:layout_centerHorizontal="true"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="3sp"
card_view:cardUseCompatPadding="true" />
<android.support.v7.widget.CardView
android:id="#+id/cardview3"
android:layout_width="120dp"
android:layout_height="180dp"
android:layout_alignParentEnd="true"
android:layout_alignTop="#+id/cardview2"
android:layout_marginEnd="7dp"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="3sp"
card_view:cardUseCompatPadding="true" />
<Button
android:id="#+id/button"
style="?android:attr/buttonStyleSmall"
android:layout_width="70dp"
android:layout_height="40dp"
android:layout_alignBaseline="#+id/textView"
android:layout_alignBottom="#+id/textView"
android:layout_alignEnd="#+id/cardview3"
android:text="#string/morebtn"
android:textColor="#ffffff" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="#layout/header"
app:menu="#menu/drawer" />
</android.support.v4.widget.DrawerLayout>
Theme: for this activity
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorPrimary">#color/ColorPrimary</item>
<item name="windowActionBar">false</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:colorButtonNormal">#43A047</item>
<!-- Customize your theme here. -->
</style>
Toolbar codes:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/ColorPrimary"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar" />
But, i cant figured out, why this is gonna happened?
Cheers!
After deleting this in V19 Layout and style, its working.
<item name="android:windowTranslucentStatus">true</item>

Categories

Resources