我想改变动作栏图标的大小 [英] I want to change actionbar icon size
本文介绍了我想改变动作栏图标的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图使用这个代码
<item
android:id="@+id/male_button"
android:layout_width="46dp"
android:layout_height="56dp"
android:layout_gravity="right"
android:icon="@drawable/icon_male"
android:showAsAction="always"
android:title="i"/>
<item
android:id="@+id/female_button"
android:layout_width="46dp"
android:layout_height="56dp"
android:layout_gravity="right"
android:icon="@drawable/icon_female"
android:showAsAction="always"
android:title="i"/>
我将android:layout_width =46dp更改为android:layout_width =30dp
但我仍然有相同的大小
所需的图像是
and I changed android:layout_width="46dp" to android:layout_width="30dp" but I still have the same size the desired image is
我现在有这个
如何将图标更改为第一张图片?
How can I change the icons to be as the first picture ?
推荐答案
要减少动作图标之间的空间,您需要在styles.xml中创建一个actionButtonStyle,并将其引用为主题(例如:AppTheme)。
To reduce the space between actions icons, in your styles.xml you need to create a actionButtonStyle and referencing it your main theme (ex: "AppTheme").
第一步(放两句话):
<style name="AppTheme" parent="Theme.AppCompat.Light">
...
<item name="android:actionButtonStyle">@style/myActionButtonStyle</item>
<item name="actionButtonStyle">@style/myActionButtonStyle</item>
...
</style>
第二步(参数android:width是伟大的秘密):
2nd step (the parameter "android:width" is the great secret):
<style name="myActionButtonStyle" parent="Widget.AppCompat.ActionButton">
<item name="android:minWidth">30dp</item>
<item name="android:maxWidth">48dp</item>
<item name="android:width">38dp</item>
</style>
享受
这篇关于我想改变动作栏图标的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文