android - How do I change the color of the ActionBar hamburger icon? -
i'm using navigationview android design support library , toolbar , works fine, want know how make hamburger icon dark (right appears white). wanna adjust distance screen edge actionbar title. how do this? help.
i set theme theme.appcompat.light.noactionbar. use toolbar. here code:
public class mainactivity extends appcompatactivity { //defining variables private toolbar toolbar; private navigationview navigationview; private drawerlayout drawerlayout; viewpager pager; viewpageradapter adapter; slidingtablayout tabs; charsequence titles[]={"Песни","Исполнители"}; int numboftabs =2; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); // initializing toolbar , setting actionbar toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar);
and xml:
<android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="false" tools:context=".mainactivity"> <linearlayout android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical" > <include android:id="@+id/toolbar" layout="@layout/tool_bar" /> <ru.amdm.amdm.slidingtablayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" android:elevation="2dp" android:background="@color/colorprimary"/> <framelayout android:layout_width="match_parent" android:layout_height="match_parent" android:foreground="?android:windowcontentoverlay"> <android.support.v4.view.viewpager android:id="@+id/pager" android:layout_height="match_parent" android:layout_width="match_parent"/> </framelayout> </linearlayout> <android.support.design.widget.navigationview android:id="@+id/navigation_view" android:layout_height="match_parent" android:layout_width="wrap_content" android:layout_gravity="start" app:headerlayout="@layout/header" app:menu="@menu/drawer" />
to change hamburger icon, create new icon (e.g. ic_my_dark_menu) assign action bar:
actionbar.sethomeasupindicator(r.drawable.ic_my_dark_menu);
or, can tint existing icon, if you'd rather way:
drawable drawable = resourcescompat.getdrawable(getresources(), r.drawable.ic_menu, null); drawable = drawablecompat.wrap(drawable); drawablecompat.settint(drawable, color.black); actionbar.sethomeasupindicator(drawable);
to change amount of space between action bar title , edge, edit toolbar layout (res/layout/tool_bar.xml). example, can add padding this:
res/layout/tool_bar.xlml
<android.support.v7.widget.toolbar ... android:paddingtop="16dp" />
Comments
Post a Comment