也许你在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终于变美啦!