How to set custom ActionBar color / style?

You can define the color of the ActionBar (and other stuff) by creating a custom Style: Simply edit the res/values/styles.xml file of your Android project. For example like this: <resources> <style name=”MyCustomTheme” parent=”@android:style/Theme.Holo.Light”> <item name=”android:actionBarStyle”>@style/MyActionBarTheme</item> </style> <style name=”MyActionBarTheme” parent=”@android:style/Widget.Holo.Light.ActionBar”> <item name=”android:background”>ANY_HEX_COLOR_CODE</item> </style> </resources> Then set “MyCustomTheme” as the Theme of your Activity that contains the … Read more

How to change color of hamburger icon in material design navigation drawer

To change color of hamburger icon you have to open “style.xml” class, then try this code: <style name=”MyMaterialTheme” parent=”MyMaterialTheme.Base”> </style> <style name=”MyMaterialTheme.Base” parent=”Theme.AppCompat.Light.DarkActionBar”> <item name=”windowNoTitle”>true</item> <item name=”windowActionBar”>false</item> <item name=”colorPrimary”>@color/colorPrimary</item> <item name=”colorPrimaryDark”>@color/colorPrimaryDark</item> <item name=”colorAccent”>@color/colorAccent</item> <item name=”drawerArrowStyle”>@style/DrawerArrowStyle</item> </style> <style name=”DrawerArrowStyle” parent=”@style/Widget.AppCompat.DrawerArrowToggle”> <item name=”spinBars”>true</item> <item name=”color”>@android:color/black</item> </style> So check <item name=”color”>@android:color/black</item> line. Just change your desired color here.

How to add one section separator for Navigation Drawer in Android?

Make sure you define each group with a unique ID, separator won’t appear without the ID. For example, this is my drawer_menu.xml: <?xml version=”1.0″ encoding=”utf-8″?> <menu xmlns:android=”http://schemas.android.com/apk/res/android”> <group android:id=”@+id/menu_top” android:checkableBehavior=”single”> <item android:checked=”true” android:id=”@+id/drawer_item_timeline” android:icon=”@drawable/ic_timer_grey600_24dp” android:title=”@string/drawer_timeline”/> <item android:id=”@+id/drawer_item_reports” android:icon=”@drawable/ic_timetable_grey600_24dp” android:title=”@string/drawer_reports”/> </group> <group android:id=”@+id/menu_bottom” android:checkableBehavior=”none”> <item android:id=”@+id/drawer_item_settings” android:icon=”@drawable/ic_settings_black_24dp” android:title=”@string/drawer_settings” > </item> </group> </menu> Gabriel adds below in … Read more

Cannot catch toolbar home button click event

If you want to know when home is clicked is an AppCompatActivity then you should try it like this: First tell Android you want to use your Toolbar as your ActionBar: setSupportActionBar(toolbar); Then set Home to be displayed via setDisplayShowHomeEnabled like this: getSupportActionBar().setDisplayShowHomeEnabled(true); Finally listen for click events on android.R.id.home like usual: @Override public boolean … Read more

How to create a simple divider in the new NavigationView?

All you need to do is define a group with an unique ID, I have checked the implementation if group has different id’s it will create a divider. Example menu, creating the separator: <menu 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=”.MainActivity”> <group android:id=”@+id/grp1″ android:checkableBehavior=”single” > <item android:id=”@+id/navigation_item_1″ android:checked=”true” android:icon=”@drawable/ic_home” android:title=”@string/navigation_item_1″ /> </group> <group android:id=”@+id/grp2″ android:checkableBehavior=”single” > <item android:id=”@+id/navigation_item_2″ … Read more

Switching between Android Navigation Drawer image and Up caret when using fragments

It’s easy as 1-2-3. If you want to achieve: 1) Drawer Indicator – when no fragments are in the Back Stack or the Drawer is opened 2) Arrow – when some Fragments are in the Back Stack private FragmentManager.OnBackStackChangedListener mOnBackStackChangedListener = new FragmentManager.OnBackStackChangedListener() { @Override public void onBackStackChanged() { syncActionBarArrowState(); } }; @Override protected void … Read more

Same Navigation Drawer in different Activities

If you want a navigation drawer, you should use fragments. I followed this tutorial last week and it works great: http://developer.android.com/training/implementing-navigation/nav-drawer.html You can also download sample code from this tutorial, to see how you can do this. Without fragments: This is your BaseActivity Code: public class BaseActivity extends Activity { public DrawerLayout drawerLayout; public ListView … Read more

Navigation drawer: How do I set the selected item at startup?

Use the code below: navigationView.getMenu().getItem(0).setChecked(true); Call this method after you call setNavDrawer(); The getItem(int index) method gets the MenuItem then you can call the setChecked(true); on that MenuItem, all you are left to do is to find out which element index does the default have, and replace the 0 with that index. You can select(highlight) … Read more

How do I use DrawerLayout to display over the ActionBar/Toolbar and under the status bar?

New functionality in the framework and support libs allow exactly this. There are three ‘pieces of the puzzle’: Using Toolbar so that you can embed your action bar into your view hierarchy. Making DrawerLayout fitsSystemWindows so that it is layed out behind the system bars. Disabling Theme.Material‘s normal status bar coloring so that DrawerLayout can … Read more

Navigation Drawer (Google+ vs. YouTube)

Edit #3: The Navigation Drawer pattern is officially described in the Android documentation! Check out the following links: Design docs can be found here. Developer docs can be found here. Edit #2: Roman Nurik (an Android design engineer at Google) has confirmed that the recommended behavior is to not move the Action Bar when opening … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)