如何为 Pre-Lollipop 设备设计 Material
How to have Material Design for Pre-Lollipop Devices
我希望为 Pre-Lollipop 设备提供相同的设计。
在我的应用程序中,我使用了一个开关按钮,它在 Lollipop 设备上看起来像这样:
以及 Pre-Lollipop 设备。它看起来像这样:
那么我该怎么做呢?我有两个样式文件夹:
我的样式 xml 看起来像:
<resources>
<style name="MyMaterialTheme" parent="MyMaterialTheme.Base">
</style>
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowActionModeOverlay">true</item>
<item name="actionModeBackground">@color/colorPrimaryDark</item>
</style>
<style name="MyMaterialTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="MyMaterialTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
您可以使用 SwitchCompat
class 而不是 Switch
来提供向后兼容性。
对于 switch 你需要使用新的 android.support.v7.widget.SwitchCompat
更多信息here
我希望为 Pre-Lollipop 设备提供相同的设计。
在我的应用程序中,我使用了一个开关按钮,它在 Lollipop 设备上看起来像这样:
以及 Pre-Lollipop 设备。它看起来像这样:
那么我该怎么做呢?我有两个样式文件夹:
我的样式 xml 看起来像:
<resources>
<style name="MyMaterialTheme" parent="MyMaterialTheme.Base">
</style>
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowActionModeOverlay">true</item>
<item name="actionModeBackground">@color/colorPrimaryDark</item>
</style>
<style name="MyMaterialTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="MyMaterialTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
您可以使用 SwitchCompat
class 而不是 Switch
来提供向后兼容性。
对于 switch 你需要使用新的 android.support.v7.widget.SwitchCompat
更多信息here