How do I change the color of the ActionBar hamburger icon?

AlexKost

I'm using NavigationView from android design support library and toolbar and everything works fine, but I want to know how to make the hamburger icon dark (right now it appears white). Also I wanna adjust distance from screen edge to ActionBar Title. So how do I do this? Thanks for help.

I set theme as Theme.AppCompat.Light.NoActionBar. So I use toolbar. Here is my 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 and setting it as the 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"
    />

hungryghost

To change the hamburger icon, just create a new icon (e.g. ic_my_dark_menu) then assign that to your action bar:

actionBar.setHomeAsUpIndicator(R.drawable.ic_my_dark_menu);

Or, you can tint your existing icon, if you'd rather do it this 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 your action bar title and the edge, just edit your toolbar layout (res/layout/tool_bar.xml). For example, you can add padding like this:

res/layout/tool_bar.xlml

<android.support.v7.widget.Toolbar
    ...
    android:paddingTop="16dp" />

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How do I change the color of desktop icon text

分類Dev

How do I hover to change the hamburger menu colour, click the hamburger menu to transform it to x and have the contents dropdown?

分類Dev

how to change the color of icon in carousel?

分類Dev

Changing the hamburger icon color in navigation drawer

分類Dev

How do I change the search box submit button icon?

分類Dev

How can i change android actionbar picture

分類Dev

How do I change the color of one vertex instead of all of them?

分類Dev

How do I change button color in Ionic Framework

分類Dev

How do I change the font color in an html table?

分類Dev

How do I change the font color of the warning box in VIM?

分類Dev

How do I implement option buttons and change the button color in PyGame?

分類Dev

How do I change the entire background color in an RMarkdown HTML Document?

分類Dev

How do I change xterm's menu background color?

分類Dev

How do I change the color of a tab when the sum of cells =0

分類Dev

Flutter: How to have a Drawer in a Scaffold but no hamburger Icon?

分類Dev

How can I make Xamarin show the hamburger icon rather than the back button?

分類Dev

How do I change a button label created with 'interact_manual' from 'ipywidgets'? and how do I change the size and color of that button?

分類Dev

how to change color of mat-icon in input in angular 6?

分類Dev

Change color of the actionbar's arrow dynamically

分類Dev

Can't change ActionBar title text color

分類Dev

Why is my actionbar not showing and how do I fix it?

分類Dev

How do I restore the Trash icon on the desktop?

分類Dev

how do I make a hexagon inherited from QraphicsPolygonItem change its color?

分類Dev

Xamarin.Forms - How do I change the background color of the screen at random times?

分類Dev

How do I change the outline color (stroke) of my shape after drawing it?

分類Dev

How do I change the font color using SCSS when it has an imported stylesheet in Angular 8?

分類Dev

Django REST Framework: How do I change the color of top strip in Browsable UI

分類Dev

How do I change the style(color) of tabs in action bar v7 of android ?

分類Dev

how can I do change color of text when pressed / after that press / again? like comment in visual

Related 関連記事

  1. 1

    How do I change the color of desktop icon text

  2. 2

    How do I hover to change the hamburger menu colour, click the hamburger menu to transform it to x and have the contents dropdown?

  3. 3

    how to change the color of icon in carousel?

  4. 4

    Changing the hamburger icon color in navigation drawer

  5. 5

    How do I change the search box submit button icon?

  6. 6

    How can i change android actionbar picture

  7. 7

    How do I change the color of one vertex instead of all of them?

  8. 8

    How do I change button color in Ionic Framework

  9. 9

    How do I change the font color in an html table?

  10. 10

    How do I change the font color of the warning box in VIM?

  11. 11

    How do I implement option buttons and change the button color in PyGame?

  12. 12

    How do I change the entire background color in an RMarkdown HTML Document?

  13. 13

    How do I change xterm's menu background color?

  14. 14

    How do I change the color of a tab when the sum of cells =0

  15. 15

    Flutter: How to have a Drawer in a Scaffold but no hamburger Icon?

  16. 16

    How can I make Xamarin show the hamburger icon rather than the back button?

  17. 17

    How do I change a button label created with 'interact_manual' from 'ipywidgets'? and how do I change the size and color of that button?

  18. 18

    how to change color of mat-icon in input in angular 6?

  19. 19

    Change color of the actionbar's arrow dynamically

  20. 20

    Can't change ActionBar title text color

  21. 21

    Why is my actionbar not showing and how do I fix it?

  22. 22

    How do I restore the Trash icon on the desktop?

  23. 23

    how do I make a hexagon inherited from QraphicsPolygonItem change its color?

  24. 24

    Xamarin.Forms - How do I change the background color of the screen at random times?

  25. 25

    How do I change the outline color (stroke) of my shape after drawing it?

  26. 26

    How do I change the font color using SCSS when it has an imported stylesheet in Angular 8?

  27. 27

    Django REST Framework: How do I change the color of top strip in Browsable UI

  28. 28

    How do I change the style(color) of tabs in action bar v7 of android ?

  29. 29

    how can I do change color of text when pressed / after that press / again? like comment in visual

ホットタグ

アーカイブ