Waz*_*_Be 27 android android-4.0-ice-cream-sandwich progress-bar
我目前正在编写一个开源项目,旨在将着名的Holo主题移植到之前版本的Android(自1,6 !!!)
一切都很好,我为我的工作感到自豪,但我现在面临的问题是让ProgressBar完全像ICS一样.
我使用了与Android源相同的xml代码:(progress_medium_holo.xml)
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate
android:drawable="@drawable/spinner_48_outer_holo"
android:pivotX="50%"
android:pivotY="50%"
android:fromDegrees="0"
android:toDegrees="1080" />
</item>
<item>
<rotate
android:drawable="@drawable/spinner_48_inner_holo"
android:pivotX="50%"
android:pivotY="50%"
android:fromDegrees="720"
android:toDegrees="0" />
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
使用相同的png:
spinner_76_outer_holo.png和spinner_76_inner_holo.png
白皮=> 
但不幸的是,我只得到一个圈...
如果你不明白我的意思,你可以在pre-ICS设备上试试这个应用程序:
https://play.google.com/store/apps/details?id=com.WazaBe.HoloDemo
完整的来源是这里:https://github.com/ChristopheVersieux/HoloEverywhere
非常感谢你的帮助

Waz*_*_Be 12
刚刚找到答案!
非常有用的帖子!
确实存在平台限制,尽管它不是您可能想到的.问题是,在API11之前,它RotateDrawable有一些原始代码要求动画顺时针旋转,检查是否toDegrees大于fromDegrees; 如果没有,两人被迫相等.如果您修改了示例以使第二个项目向前移动(从0到720,甚至是-720到0),则两个图像在所有平台上都可以正常显示; 虽然我意识到这违背了你的目标.
看一下Google Codesearch所拥有的缓存版本RotateDrawable.inflate(),这是用于将XML转换为对象的方法的2.3版本,您将看到我的意思.
RotateDrawable.java ......有问题的代码在第235行附近......
float fromDegrees = a.getFloat(
com.android.internal.R.styleable.RotateDrawable_fromDegrees, 0.0f);
float toDegrees = a.getFloat(
com.android.internal.R.styleable.RotateDrawable_toDegrees, 360.0f);
toDegrees = Math.max(fromDegrees, toDegrees); //<--There's the culprit
Run Code Online (Sandbox Code Playgroud)
这需要一个XML块,就像你在那里的第二个项目一样,并将其转换为RotateDrawable最终具有相同值fromDegrees和toDegrees(在你的情况下为720)的值,从而使图像保持静止.您可以通过将起始值设置为某个值而不是360的倍数(如765)来显示测试结果.您将看到图像仍然没有动画,但会旋转到初始坐标.
在Honeycomb/ICS源中删除了这个尴尬的检查,这就是为什么你可以在这些平台上进行向后旋转的原因.此外,看起来没有办法从Java代码设置这些值,因此RotateDrawableCompat您的未来可能会有自定义:)
HTH
| 归档时间: |
|
| 查看次数: |
9809 次 |
| 最近记录: |