pja*_*cze 110 android android-3.0-honeycomb android-4.0-ice-cream-sandwich android-actionbar
是否可以更改操作栏中的溢出图标?我有所有ActionBar项目的蓝色图标,我还想在出现时更改溢出图标.
adn*_*eal 253
您可以使用样式,但必须将其添加到主要主题声明中.
<resources>
<!-- Base application theme. -->
<style name="Your.Theme" parent="@android:style/Theme.Holo">
<!-- Pointer to Overflow style ***MUST*** go here or it will not work -->
<item name="android:actionOverflowButtonStyle">@style/OverFlow</item>
</style>
<!-- Styles -->
<style name="OverFlow" parent="@android:style/Widget.Holo.ActionButton.Overflow">
<item name="android:src">@drawable/ic_action_overflow</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
你也可以动态地改变它,我在这里详细介绍:
use*_*401 16
对于那些无法让它工作的人尝试这个没有"android:"命名空间.
<item name="actionOverflowButtonStyle">@style/OverFlow</item>
Run Code Online (Sandbox Code Playgroud)
在styles.xml 中更改Actionbar 的自定义溢出图标。
<resources>
<!-- Base application theme. -->
<style name=“MyTheme" parent="@android:style/Theme.Holo">
<!-- Pointer to Overflow style DONT forget! -->
<item name="android:actionOverflowButtonStyle">@style/MyOverFlow</item>
</style>
<!-- Styles -->
<style name="MyOverFlow" parent="@android:style/Widget.Holo.ActionButton.Overflow">
<item name="android:src">@drawable/ic_your_action_overflow</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)将自定义主题“MyTheme”放在 AndroidManifest.xml 的应用程序标签中
<application
android:name="com.example.android.MainApp"
android:theme="@style/AppTheme">
</application>
Run Code Online (Sandbox Code Playgroud)玩得开心。@。@
无论我尝试做什么styles.xml,没有一个解决方案对我有用。最后,如果您有 AppCompat 23+(您应该这样做),这是实际有效的最简单方法:
toolbar.setOverflowIcon(drawable);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
61899 次 |
| 最近记录: |