Android 手机卫士(3) ProgressBar变得很丑

来源:互联网 发布:江宁区高新园网络问政 编辑:程序博客网 时间:2024/04/27 17:49

也许你在AndroidManifest.xml中将默认的主题更改成别的Theme,例如:
android:theme="@android:style/Theme.Light.NoTitleBar
没瑕疵!

但是偏偏用到ProgressBar的时候,会发现它没有想象中的好看【细+瘦】,而是【粗+大】。

为什么?
一般这是因为你采用的Theme版本都比较老旧了;里面维护的ProgressBar是以前的style。

解决方案
既然默认主题【已知】

android:theme="@style/AppTheme"

已经把ProgressBar变得漂亮了,那么我们就模仿一下把我们设置的theme主题的功能实现在默认主题下不就好了么?

举个例子
我想去除TitleBar,所以采用了:

android:theme="@android:style/Theme.Light.NoTitleBar

但是这时候我的progressbar变丑了,不得不变为原来的默认主题。

解决:既然默认主题下面没有去掉TitleBar的功能,咱们自己添加进去不就OK了!

不得不马不停蹄的查看了一下NoTitleBar的实现细节:

<!-- Variant of {@link #Theme_Light} with no title bar -->    <style name="Theme.Light.NoTitleBar">        <item name="android:windowNoTitle">true</item>    </style>

そですね
原来去头的行为只要一句话。那么我们只需要在默认主题下实现这个去头!

<!-- Application theme. -->    <style name="AppTheme" parent="AppBaseTheme"> <!-- All customizations that are NOT specific to a particular API-level can go here. --> <!-- ADD -->    <item name="android:windowNoTitle">true</item></style>

现在使用修改过后的默认主题,运行你的程序~
ProgressBar终于变美啦!

原创粉丝点击