Gau*_*rav 55 android android-actionbar
是否可以更改操作栏上的溢出按钮(3个垂直点)的颜色?如果是这样,我们该怎么做?我没有找到溢出按钮的任何样式.
谢谢
XGo*_*het 67
您可以使用以下样式声明更改用于它的图像.
<style name="MyCustomTheme" parent="style/Theme.Holo">
<item name="android:actionOverflowButtonStyle">@style/MyCustomTheme.OverFlow</item>
</style>
<style name="MyCustomTheme.OverFlow">
<item name="android:src">@drawable/my_overflow_image</item>
</style>
Run Code Online (Sandbox Code Playgroud)
如果你正在使用ActionBarSherlock,这里是如何做到的
<style name="MyCustomTheme" parent="style/Theme.Sherlock">
<item name="android:actionOverflowButtonStyle">@style/MyCustomTheme.OverFlow</item>
<item name="actionOverflowButtonStyle">@style/MyCustomTheme.OverFlow</item>
</style>
<style name="MyCustomTheme.OverFlow">
<item name="android:src">@drawable/my_overflow_image</item>
</style>
Run Code Online (Sandbox Code Playgroud)
Pet*_*fin 21
其中一些答案严重矫枉过正,有些答案有限.答案要简单得多.您可以随时将其设置为您想要的任何颜色.这里:
toolbar.getOverflowIcon().setColorFilter(colorInt, PorterDuff.Mode.SRC_ATOP);
Run Code Online (Sandbox Code Playgroud)
小智 20
XGouchet的答案很棒,但只是想补充一点,如果从现有的样式继承,你将获得标准填充,选择状态等.
<style name="MyCustomTheme.OverFlow" parent="Widget.Sherlock.ActionButton.Overflow">
<item name="android:src">@drawable/title_moreicon</item>
</style>
Run Code Online (Sandbox Code Playgroud)
如果您使用的是AppCompat,则可以使用android:textColorSecondary设置为所需颜色的属性派生新的自定义样式,并将其用作工具栏的主题.
Android:更改工具栏的文本颜色和溢出图标颜色
其他以编程方式选择:
Drawable drawable = toolbar.getOverflowIcon();
if(drawable != null) {
drawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(drawable.mutate(), getResources().getColor(R.color.thecolor));
toolbar.setOverflowIcon(drawable);
}
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你!
| 归档时间: |
|
| 查看次数: |
31298 次 |
| 最近记录: |