@@ -35,7 +35,7 @@ In `Build.gradle` of app module, include these dependencies.
35
35
dependencies {
36
36
37
37
// Material Navigation View Library
38
- implementation 'com.shreyaspatil:MaterialNavigationView:1.0 '
38
+ implementation 'com.shreyaspatil:MaterialNavigationView:1.1 '
39
39
40
40
// Material Design Library
41
41
implementation 'com.google.android.material:material:1.0.0'
@@ -91,6 +91,16 @@ As already mentioned, this class is inherited from `NavigationView`. You can use
91
91
New important flag here is.
92
92
- ` itemStyle ` - Points to a style of menu item of Navigation drawer. <br >
93
93
There are currently 2 menu styles are defined as below
94
+ - ` default_style ` : This flag sets default design style to menu item of Navigation drawer as you can see below.<br >
95
+ <img src =" Images/DefaultStyle.png " height =" 200 " />
96
+
97
+ Implemented as follows:
98
+ ```xml
99
+ <com.shreyaspatil.material.navigationview.MaterialNavigationView
100
+ ...
101
+ app: itemStyle ="default_style"/>
102
+ ```
103
+
94
104
- ` rounded_right ` : This flag sets design to menu item of Navigation drawer as *** Rounded Corners at right*** as you can see below.<br >
95
105
<img src =" Images/RoundRightFull.png " height =" 200 " />
96
106
@@ -119,6 +129,7 @@ All the programmatic way of implementation of `MaterialNavigationView` is same a
119
129
Two methods are added in this new class as follows..
120
130
- *** ` setItemStyle(int itemStyle) ` *** : This method sets the Item Style of Menu in MaterialNavigationView at runtime.
121
131
` itemStyle ` should be one of the following constants :
132
+ - ` MaterialNavigationView.ITEM_STYLE_DEFAULT `
122
133
- ` MaterialNavigationView.ITEM_STYLE_ROUND_RIGHT `
123
134
- ` MaterialNavigationView.ITEM_STYLE_ROUND_RECTANGLE `
124
135
- *** ` getItemStyle() ` *** : It returns the value of item style of menu.
@@ -138,13 +149,17 @@ class MainActivity : AppCompatActivity() {
138
149
}
139
150
140
151
override fun onOptionsItemSelected (item : MenuItem ): Boolean {
141
- val itemStyle = when (item.itemId) {
142
- R .id.action_round_rect -> MaterialNavigationView .ITEM_STYLE_ROUND_RECTANGLE
143
- R .id.action_round_right -> MaterialNavigationView .ITEM_STYLE_ROUND_RIGHT
144
- else -> MaterialNavigationView .ITEM_STYLE_ROUND_RIGHT
152
+ when (item.itemId) {
153
+ R .id.action_default -> {
154
+ navView.setItemStyle(MaterialNavigationView .ITEM_STYLE_DEFAULT )
155
+ }
156
+ R .id.action_round_rect -> {
157
+ navView.setItemStyle(MaterialNavigationView .ITEM_STYLE_ROUND_RECTANGLE )
158
+ }
159
+ R .id.action_round_right -> {
160
+ navView.setItemStyle(MaterialNavigationView .ITEM_STYLE_ROUND_RIGHT )
161
+ }
145
162
}
146
- navView.setItemStyle(itemStyle)
147
-
148
163
return false
149
164
}
150
165
}
0 commit comments