【问题标题】:How to have Material Design for Pre-Lollipop Devices如何为 Pre-Lollipop 设备进行材料设计
【发布时间】:2015-10-10 20:50:06
【问题描述】:

我希望为 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" />

【问题讨论】:

    标签: android android-5.0-lollipop android-design-library


    【解决方案1】:

    您可以使用SwitchCompat 类而不是Switch 来提供向后兼容性。

    【讨论】:

      【解决方案2】:

      对于 switch,你需要使用新的 android.support.v7.widget.SwitchCompat

      更多信息here

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-01-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-09-26
        • 1970-01-01
        • 2015-09-18
        相关资源
        最近更新 更多