【问题标题】:Toolbar item color (3 dots)工具栏项目颜色(3 个点)
【发布时间】:2017-01-31 14:25:55
【问题描述】:

我知道当我在大多数 ui 元素中设置“colorControlNormal”颜色更改时,我只需要更改工具栏中的项目。

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="toolbarStyle">@style/ToolBar</item>
    <item name="android:statusBarColor">@color/PrimaryDarkGreen</item>

    <item name="colorPrimary">@color/PrimaryGreen</item>
    <item name="colorAccent">@color/AccentGreen</item>
    <item name="colorControlNormal">@color/PrimaryWhite</item>        
</style>

<style name="ToolBar" parent="Widget.AppCompat.Toolbar">
    <item name="android:background">@color/PrimaryGreen</item>
</style>

更新 screenshot

【问题讨论】:

    标签: android android-toolbar nativescript android-theme angular2-nativescript


    【解决方案1】:

    这里有什么问题?您还可以在工具栏主题中为 colorControlNormal 分配一个值。检查此链接。

    Android Support Toolbar colorControlNormal color

    【讨论】:

      【解决方案2】:

      检查这个。这将更改溢出按钮(3 个点)。

      public  PorterDuffColorFilter colorFilterWhite= new PorterDuffColorFilter( getResources().getColor(R.color.textColorPrimary), PorterDuff.Mode.MULTIPLY);
      final String overflowDescription = getString(R.string.abc_action_menu_overflow_description);
      final ViewGroup decorView = (ViewGroup) getWindow().getDecorView();
      final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver();
      
      
              viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                  @Override
                  public void onGlobalLayout() {
                      final ArrayList<View> outViews = new ArrayList<View>();
                      decorView.findViewsWithText(outViews, overflowDescription,
                              View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
                      if (outViews.isEmpty()) {
                          return;
                      }
                      AppCompatImageView overflow=(AppCompatImageView) outViews.get(0);
                      overflow.setColorFilter(colorFilterWhite);
                      if(viewTreeObserver.isAlive())
                          viewTreeObserver.removeOnGlobalLayoutListener(this);
                      else
                          decorView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                  }
              });
      

      【讨论】:

        【解决方案3】:
        toolbar.setBackgroundColor(Color.parseColor("#80000000"));
        

            <android.support.v7.widget.Toolbar
                android:id="@+id/home_toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"/>
        

        在 Java 文件或 XML 中进行更改。

        【讨论】:

        • 我需要更改工具栏中的项目,而不是背景。
        • 问题是关于工具栏中的项目而不是背景
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-05-19
        • 1970-01-01
        • 2020-07-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多