Jun*_*Jun 26 android toolbar overflow android-appcompat actionmode
使用AppCompat工具栏,我希望能够在ActionMode更改时更改溢出菜单图标的颜色.
例如,在正常工具栏模式下,溢出图标将为白色.并且会在ActionMode上变黑.到目前为止,我已经设法改变了动作模式的背景以及标题文本.但我还没有找到一种方法来改变溢出菜单图标的颜色.
我知道有一个答案: 更改ActionMode Overflow图标
我尝试了第一个解决方案,但我无法找到溢出图标.
第二种解决方案,即使延迟50L,也会导致溢出菜单图标闪烁ActionMode的预期颜色,短时间内非常刺耳.
Piy*_*ush 61
将以下行添加到您的主题属性中:
<item name="android:textColorSecondary">@android:color/white</item>
Run Code Online (Sandbox Code Playgroud)
Pat*_*ren 16
这可以通过设置android:textColorSecondary主题属性来实现.
例如,假设您有以下工具栏,它使用主题MyToolbarStyle:
<android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
theme="@style/MyToolbarStyle"
/>
Run Code Online (Sandbox Code Playgroud)
接下来,定义MyToolbarStyle继承自的样式ThemeOverlay.AppCompat.ActionBar.最后,通过添加以下项目来修改溢出图标的颜色android:textColorSecondary:
<style name="MyToolbarStyle" parent="ThemeOverlay.AppCompat.ActionBar">
<item name="android:textColorSecondary">#333333</item>
</style>
Run Code Online (Sandbox Code Playgroud)
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:actionOverflowButtonStyle">@style/ActionButtonOverflow</item>
<!-- Support library compatibility -->
<item name="actionOverflowButtonStyle">@style/ActionButtonOverflow</item>
</style>
<style name="ActionButtonOverflow" parent="@style/Widget.AppCompat.ActionButton.Overflow">
<item name="android:tint">@color/brand_white</item>
</style>
Run Code Online (Sandbox Code Playgroud)
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:actionOverflowButtonStyle">@style/ActionButton.Overflow.Icon</item>
</style>
<style name="ActionButton.Overflow.Icon" parent="android:style/Widget.Holo.Light.ActionButton.Overflow">
<item name="android:src">@mipmap/yourwanticon</item>
</style>
Run Code Online (Sandbox Code Playgroud)
小智 6
<style name="ToolBarTheme" parent="ThemeOverlay.AppCompat.ActionBar">
<item name="android:tint">@color/colorAccent</item>
Run Code Online (Sandbox Code Playgroud)
使用您的颜色创建上述 theme.set 色调,并将该主题添加到工具栏。
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ToolBarTheme"/>
Run Code Online (Sandbox Code Playgroud)
将此代码添加到 res->styles.xml
<style name="ToolbarColored" parent="AppTheme">
<item name="android:textColorSecondary">YOUR_COLOR</item>
</style>
Run Code Online (Sandbox Code Playgroud)
然后你的 XML 文件中的“ToolbarColored”样式就像 belove
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
app:theme="@style/ToolbarColored"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
34563 次 |
| 最近记录: |