Cor*_*Roy 2 android android-5.0-lollipop
正如您所看到的,背景在弹出窗口后面扭曲了.它只发生在棒棒糖上!请不要被我的样式文件中的所有x_弄糊涂.我刚刚对代码进行了去标记.

在主题文件中:
<style name="core" parent="Theme.AppCompat.Light">
<!-- Popup menu -->
<item name="android:popupMenuStyle">@style/x_popup_menu_theme</item>
<item name="android:textAppearanceSmallPopupMenu">@style/x_popup_menu_small_text</item>
<item name="android:textAppearanceLargePopupMenu">@style/x_popup_menu_large_text</item>
</style>
Run Code Online (Sandbox Code Playgroud)
在v21/themes_styles.xml中
<style name="x_popup_menu_theme" parent="Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">@color/x_navy_dark</item>
</style>
<style name="x_popup_menu_large_text" parent="TextAppearance.AppCompat.Widget.PopupMenu.Large">
<item name="android:textColor">@color/std_white</item>
</style>
<style name="x_popup_menu_small_text" parent="TextAppearance.AppCompat.Widget.PopupMenu.Small">
<item name="android:textColor">@color/std_white</item>
</style>
Run Code Online (Sandbox Code Playgroud)
如果我更改/删除样式,它的工作原理如下图所示.

<style name="x_popup_menu_theme" parent="Widget.AppCompat.PopupMenu">
</style>
<style name="x_popup_menu_large_text" parent="TextAppearance.AppCompat.Widget.PopupMenu.Large">
</style>
<style name="x_popup_menu_small_text" parent="TextAppearance.AppCompat.Widget.PopupMenu.Small">
</style>
Run Code Online (Sandbox Code Playgroud)
Android 5.0.x中有一个错误(在5.1中已修复),@color在高架窗口中设置不透明(例如)背景会导致视觉瑕疵.
作为5.0.x设备的变通方法,您可以将背景设置为非不透明的可绘制对象,例如圆角矩形.
RES /绘制/ my_popup_bg.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="@color/x_navy_dark" />
</shape>
Run Code Online (Sandbox Code Playgroud)
RES /值/ styles.xml:
...
<style name="x_popup_menu_theme" parent="Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">@drawable/my_popup_bg</item>
</style>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
975 次 |
| 最近记录: |