使Android原生时间选择器样式为滚轮

本文介绍了如何将Android原生时间选择器的样式更改为滚轮样式。主要步骤包括在styles.xml文件中创建自定义主题,继承自`android:Theme.Holo.Light`,并在`AndroidManifest.xml`中将应用的主题设置为新建的主题`AppTheme`。通过这个方法,可以实现时间选择器的视觉效果变化。

很简单,修改styles.xml代码

    <style name="AppBaseTheme" parent="android:Theme.Light">

        <!--

            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. -->

    </style>


为:

    <style name="AppBaseTheme" parent="android:Theme.Holo.Light">

        <!--

            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. -->

    </style>



然后

AndroidManifest.xml文件中设置android:theme="@style/AppTheme"

    <application

        android:name=".AppContext"

        android:allowBackup="true"

        android:icon="@drawable/logo"

        android:label="@string/app_name"

        android:launchMode="singleTask"

        android:screenOrientation="portrait"

        android:theme="@style/AppTheme" >

   </application>


 运行程序可观察前后对比效果






评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值