Bu dersimizde navigation drawer için navigation viewer kullanacağız. Daha önceki videolarda yaptığımız navigation drawer de recyclerview kullanmıştık. Bu derste navigation view kullanarak basit ve hızlı bir şekilde nasıl menumüzü oluştururuz onu anlatmaya çalıştım.
Projenin bitmiş halini indirmek için burayı tıklayın…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
<?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" tools:context="com.example.emrealtunbilek.navigationviewornekapp.MainActivity" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" android:id="@+id/drawer_layout" > <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" > <android.support.v7.widget.Toolbar android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/toolbar" android:background="@color/colorPrimary" android:minHeight="?attr/actionBarSize" android:layout_alignParentTop="true" app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" ></android.support.v7.widget.Toolbar> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="MENU ITEM" android:id="@+id/tvBaslik" android:textSize="35sp" /> </RelativeLayout> <android.support.design.widget.NavigationView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/nav_view" android:layout_gravity="start" app:headerLayout="@layout/header" app:menu="@menu/menu_items_with_header" ></android.support.design.widget.NavigationView> </android.support.v4.widget.DrawerLayout> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
<?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="190dp" android:background="@drawable/header_background"> <!-- Subtitle : 56dp --> <!-- Name: Roboto Medium, 14sp, #FFFFFF --> <!-- Email address: Roboto Regular, 14sp, #FFFFFF --> <LinearLayout android:layout_width="match_parent" android:layout_height="56dp" android:layout_alignParentBottom="true" android:orientation="vertical" android:paddingBottom="15dp" android:paddingLeft="15dp"> <TextView android:id="@+id/txvName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:fontFamily="sans-serif-medium" android:gravity="bottom" android:text="Emre Altunbilek" android:textColor="#FFFFFF" android:textSize="14sp"/> <TextView android:id="@+id/txvEmail" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:fontFamily="sans-serif" android:gravity="bottom" android:text="emrealtunbilek@gmail.com" android:textColor="#FFFFFF" android:textSize="14sp"/> </LinearLayout> </RelativeLayout> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<resources> <string name="app_name">NavigationViewOrnekApp</string> <string name="header_web_front_ent">Web Front End</string> <string name="header_back_end">Back End</string> <string name="header_mobile">Mobile</string> <string name="drawer_open">Open</string> <string name="drawer_close">Close</string> <string name="android">Android</string> <string name="ios">iOS</string> <string name="windows">Windows</string> <string name="blackberry">Blackberry</string> <string name="ionic">Ionic</string> <string name="css">CSS</string> <string name="html">HTML</string> <string name="ruby">Ruby</string> <string name="php">PHP</string> <string name="python">Python</string> </resources> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <!--This drawer menu has items Only without any group or classification --> <item android:id="@+id/item_android" android:checkable="true" android:icon="@drawable/ic_android" android:title="@string/android"/> <item android:id="@+id/item_ios" android:checkable="true" android:icon="@drawable/ic_ios" android:title="@string/ios"/> <item android:id="@+id/item_windows" android:checkable="true" android:icon="@drawable/ic_windows" android:title="@string/windows"/> <item android:id="@+id/item_blackberry" android:checkable="true" android:icon="@drawable/ic_blackberry" android:title="@string/blackberry"/> <item android:id="@+id/item_ionic" android:checkable="true" android:icon="@drawable/ic_ionic" android:title="@string/ionic"/> <item android:id="@+id/item_css" android:checkable="true" android:icon="@drawable/ic_css" android:title="@string/css"/> <item android:id="@+id/item_html" android:checkable="true" android:icon="@drawable/ic_html" android:title="@string/html"/> <item android:id="@+id/item_ruby" android:checkable="true" android:icon="@drawable/ic_ruby" android:title="@string/ruby"/> <item android:id="@+id/item_php" android:checkable="true" android:icon="@drawable/ic_php" android:title="@string/php"/> <item android:id="@+id/item_python" android:checkable="true" android:icon="@drawable/ic_python" android:title="@string/python"/> </menu> |