Android 5.x特性概览二

本文介绍了如何在Android5.X中使用MaterialDesign的三种默认主题,并展示了如何通过自定义样式来实现颜色风格的一致性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 上文 ,对Android 5.X特性,主要是Material Design的特性进行了介绍,这篇文章我们来使用Material Design主题。

  Material Design 现在有三种默认的主题可以设置,相应源代码如下所示:


@android:style/Theme.Material (dark version)
@android:style/Theme.Material.Light (light version)
@android:style/Theme.Material.Light.DarkActionBar

 效果图如下所示:

  在Android5.x中引入了colour Palette的概念,Color Palette 让app的开发者自己设定系统区域颜色,从而使整个app的颜色与系统区域的颜色来保持相互的统一。


 <style name="AppBaseTheme" parent="android:Theme.Material">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.

        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">

        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
        <item name="android:colorPrimary">#bebebe</item>
        <item name="android:colorPrimaryDark">#FF5AEBFF</item>
        <!-- theme UI controls like checkboxes and text fields -->
        <item name="android:navigationBarColor">#FFFF4130</item>
    </style>

  譬如,使用上述xml代码,用户就能够自定义自己的 Style 来创建自己的Palette,从而实现不同的颜色风格。效果图如下所示:



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值