设置 Toolbar(ActionBar) 上的按钮颜色
程序员文章站
2022-06-03 13:01:26
...
原文地址:
https://*.com/a/29536902
https://*.com/a/27754099
[your_layout.xml]
Styles / Themes in styles.xml
Result
Note: I made the checkbox purple for demo purpose
-----------------------------------------------------------
Change arrow color of Spinner
1) In styles.xml, add the following style:
2) In the layout, where you use the Spinner (in your case with Toolbar), add the style to your spinner:
https://*.com/a/29536902
https://*.com/a/27754099
[your_layout.xml]
<android.support.v7.widget.Toolbar <!-- leave the theme stuff out of here --> style="@style/MyToolbarStyle" android:layout_width="match_parent" android:layout_height="wrap_content">
Styles / Themes in styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <!-- your other attributes --> <!-- following is used to tint the checkbox - purple for demo purpose --> <item name="colorControlNormal">#2196F3</item> </style> <style name="MyToolbarStyle"> <item name="android:minHeight">?actionBarSize</item> <item name="android:background">?colorPrimary</item> <item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item> <item name="theme">@style/MyToolbarTheme</item> </style> <style name="MyToolbarTheme"> <!-- Used to tint the back arrow, menu and spinner arrow --> <item name="colorControlNormal">#FFF</item> </style>
Result
Note: I made the checkbox purple for demo purpose
-----------------------------------------------------------
Change arrow color of Spinner
1) In styles.xml, add the following style:
<style name="ActionBarThemeOverlay" parent=""> <item name="android:textColorPrimary">#ffffff</item> <item name="colorControlNormal">#ffffff</item> <item name="colorControlHighlight">#ff33b5e5</item> </style> <style name="Widget.MyTheme.HeaderBar.Spinner" parent="Widget.AppCompat.Light.Spinner.DropDown.ActionBar"> <item name="android:theme">@style/ActionBarThemeOverlay</item> </style>
2) In the layout, where you use the Spinner (in your case with Toolbar), add the style to your spinner:
<Spinner xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/my_spinner" style="@style/Widget.MyTheme.HeaderBar.Spinner" android:layout_width="wrap_content" android:layout_height="wrap_content" />
推荐阅读
-
Android编程实现简单设置按钮颜色的方法
-
Android编程实现简单设置按钮颜色的方法
-
关于Linux系统(Ubuntu14.04)上QComboBox设置qss样式表字体颜色color属性不生效或只对下拉列表生效的解决方案
-
Androidx,actionbar实现左上角保存按钮的设置
-
设置 Toolbar(ActionBar) 上的按钮颜色
-
Android Studio 界面布局之xml文件中给输入框editText修改下划线颜色 / 为按钮设置圆角和颜色 / 约束布局预览效果和运行效果不一致 问题的解决
-
在窗口中设置三个“圆形”“扇形”“矩形”按钮,点击按钮,将图形变为相应的形状(实心),设置三个“红色”“绿色”“蓝色”滚动条,滑动滚动条变换图形的颜色,设置一个控制左右移动的滚动条,点击滚动条变换图形
-
1)编写一个程序。要求:在窗体上创建一个文本框组件、两个命令按钮组件,命令按钮的标题分别设置为“隐藏”和“退出”, 窗体背景色设置为“粉红”。单击“隐藏”按钮后文本框消失,该按钮标题变为“显示”,单击
-
css怎么设置按钮边框的颜色
-
css怎么设置按钮边框的颜色