【问题标题】:Support preLollipop devices at custom styles支持自定义样式的 preLollipop 设备
【发布时间】:2015-09-02 11:26:44
【问题描述】:

我正在 Android 中自定义样式,我想知道是否可以在 preLollipop 设备中支持此样式。

现在,我在 values 文件夹中有这个 .xml,我正在使用 Android Studio。

有什么推荐吗?

谢谢

<resources xmlns:tools="http://schemas.android.com/tools">

    <style name="GradiantTheme" parent="android:Theme.DeviceDefault.Light.NoActionBar">

        <!-- App background color -->
        <item name="android:windowBackground">@color/theme_background</item>

        <!--Transparent status bar-->
        <item name="android:windowTranslucentStatus" tools:targetApi="kitkat">true</item>


        <!--   texts -->
        <item name="android:textColor" tools:targetApi="lollipop">@color/gradiant</item>


        <!--   theme UI controls like checkboxes and text fields -->
        <item name="android:colorAccent" tools:targetApi="lollipop">@color/gradiant</item>


    </style>




</resources>

【问题讨论】:

    标签: android styles


    【解决方案1】:

    对于旧版本,请检查项目中的两个文件夹: 价值观-v11:

        <!--
            Base application theme for API 11+. This theme completely replaces
            AppBaseTheme from res/values/styles.xml on API 11+ devices.
        -->
        <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
            <!-- API 11 theme customizations can go here. -->
        </style>
    
    </resources>
    

    价值观-v14:

    <resources>
    
        <!--
            Base application theme for API 14+. This theme completely replaces
            AppBaseTheme from BOTH res/values/styles.xml and
            res/values-v11/styles.xml on API 14+ devices.
        -->
        <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
            <!-- API 14 theme customizations can go here. -->
        </style>
    
    </resources>
    

    【讨论】:

      【解决方案2】:

      您的默认值文件夹仅适用于棒棒糖之前的设备。如果您创建一个 values-v21 文件夹,那么其中的样式将专门用于支持棒棒糖版本的设备。例如,您可以将棒棒糖过渡效果放在 values-v21 文件夹的样式 xml 中,因为它仅受棒棒糖支持。 如果您只想更改棒棒糖前设备的样式,那么只需在默认值文件夹中的样式 xml 中进行这些更改。 希望以上描述对您有所帮助。

      【讨论】:

      • 如果你投了反对票,你必须解释为什么?我写的描述是绝对正确的,因为我自己已经实现了!!
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-05
      相关资源
      最近更新 更多