简体   繁体   中英

Android: Changing color of the back button in tool bar

I am trying to make the back button on the toolbar black, but I can't find a way. For some reason I don't have toolBar in my xml file, so there is no way to change the color for me. Please let me know if there is another way.

工具栏的照片

I have the primaryColor white, but the back button is also white.

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="colorControlNormal">@color/colorPrimaryDark</item>
    <item name="actionMenuTextColor">@color/colorPrimaryDark</item>
</style>

This is my xml file

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Space
        android:layout_width="match_parent"
        android:layout_height="40dp" />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textPersonName"
        android:ems="10"
        android:id="@+id/taskNameEditText"
        android:textAlignment="center"
        android:hint="enter task name"/>

    <HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:id="@+id/scrollLinearLayout">

        </LinearLayout>
    </HorizontalScrollView>

    <Space
        android:layout_width="match_parent"
        android:layout_height="40dp" />

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:inputType="textPersonName"
            android:ems="10"
            android:id="@+id/fromTimeEditText"
            android:layout_weight="1"
            android:hint="fromTime"
            android:textAlignment="center" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:inputType="textPersonName"
            android:ems="10"
            android:id="@+id/toTimeEditText"
            android:layout_weight="1"
            android:hint="toTime"
            android:textAlignment="center" />
    </LinearLayout>

</LinearLayout>

如果使用工具栏,则可以更改

toolbar.getNavigationIcon().setColorFilter(getResources().getColor(R.color.blue_gray_15), PorterDuff.Mode.SRC_ATOP);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM