更改工具栏的后退箭头颜色 [英] Change toolbar back arrow color

查看:101
本文介绍了更改工具栏的后退箭头颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.在上面的图片中,您可以看到向后箭头和标题的一部分.我使用所附的.xml代码更改了标题颜色.但是我也想将后退箭头也涂成白色.

Hi. In the picture above you can see a back arrow and a (part of) title. I changed the title color using the attached .xml code. But I want to color the back arrow to white too.

我在互联网上阅读了一些答案,但是对于这样一个简单的问题,它们看起来太复杂了.

I read some answer on the internet, but they look too complicated for such a simple question.

有什么简单的理由吗?

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="fill_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/colorPrimary"
        android:minHeight="?attr/actionBarSize"
        app:titleTextColor="@android:color/white"/>

import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
//...

public class LoginActivity extends AppCompatActivity {
    protected void onCreate(Bundle savedInstanceState) {

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
      //...
    }
    //...
}

推荐答案

您可以在工具栏中使用主题.

You can use a Theme in your Toolbar.

<android.support.v7.widget.Toolbar
  android:theme="@style/myToolbarTheme" 
  ...
>

然后在主题中定义colorControlNormal属性:

Then in your theme you can define the colorControlNormal attribute:

   <style name=""  parent="ThemeOverlay.AppCompat.Dark.ActionBar">
      ....
      <item name="colorControlNormal">@color/myColor</item>  
   </style>

这篇关于更改工具栏的后退箭头颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆