今天接触到了menu弹出框样式。主要就是在theme下进行调整。现在把接触到的知识点总结一下。
在theme中,跟menu有关的几个属性如下
<item name="panelBackground">@android:drawable/menu_panel_color_funui</item> <item name="panelFullBackground">@android:drawable/menu_background_fill_parent_width</item> <!-- These three attributes do not seems to be used by the framework. Declared public though --> <item name="panelColorBackground">#000</item> <item name="panelColorForeground">?android:attr/textColorPrimary</item> <item name="panelTextAppearance">?android:attr/textAppearance</item> <item name="panelMenuIsCompact">true</item> <item name="panelMenuListWidth">250dip</item> <item name="panelMenuListTheme">@android:style/Theme.Funui.CompactMenu</item>
今天接触到的是一下几个
<item name="panelBackground">@android:drawable/menu_panel_color_funui</item>
决定的是menu弹出框的背景颜色。看效果
<item name="panelBackground">#0000ff</item>
结果
<item name="panelMenuListWidth">250dip</item>
决定的是弹出框的宽度
看效果(“搜索“两个字位置)
<item name="panelMenuListWidth">100</item>
<item name="panelMenuListTheme">@android:style/Theme.Funui.CompactMenu</item>
这个主要是决定了弹出框的样式,包括每个Item的字体颜色跟大小,item之间分割线颜色,弹出框动画等。
它的内容如下
<style name="Theme.Funui.CompactMenu"> <!-- Menu/item attributes --> <item name="android:itemTextAppearance">@style/Email.Theme.Menu.TextAppearance</item> <item name="android:listViewStyle">@style/Email.Theme.ListView.Menu</item> <item name="android:windowAnimationStyle">@style/Email.Theme.Menu.Animation</item> <item name="android:background">@null</item> </style>
它几个属性如下
<style name="Email.Theme.Menu.Animation" parent="@style/Animation.AppCompat.DropDownUp"> <item name="android:windowEnterAnimation">@anim/menu_enter_from_bottom</item> <item name="android:windowExitAnimation">@anim/menu_out_from_bottom</item> </style>
动画效果。不做解释
<style name="Email.Theme.Menu.TextAppearance" parent="@style/Base.TextAppearance.AppCompat.Medium"> <item name="android:textSize">@dimen/panel_menu_text_size</item> <item name="android:textColor">@color/panel_menu_text_color</item> </style>
字体大小跟颜色,不解释
<style name="Email.Theme.ListView.Menu" parent="@style/Base.Widget.AppCompat.ListView.Menu"> <item name="android:divider">@color/panel_listview_menu_divider_color</item> </style>
分割线颜色,不解释