Android RotatedRavable:dons';不能正确地使用矢量牵引
在Android RotatedRavable:dons';不能正确地使用矢量牵引,android,svg,vector,rotation,android-drawable,Android,Svg,Vector,Rotation,Android Drawable,在旋转牵引中使用矢量牵引时观察到一个奇妙的问题,每个完整循环两次(0°到360°/水平:0→ 10000)!首先约为90°(标高:2500),然后约为270°(标高:7500)。请参见以下测试: 我的rotatedravable(文件名:rotatable\u info.xml): 似乎是一只虫子vectorDrawables.useSupportLibrary=true解决了该问题 有关详细信息,请参阅下页的“Vector drawables向后兼容解决方案”部分: @pskink;你的意思
旋转牵引中使用矢量牵引时观察到一个奇妙的问题,每个完整循环两次(0°到360°/水平:0→ 10000
)!首先约为90°(标高:2500
),然后约为270°(标高:7500
)。请参见以下测试:
我的rotatedravable
(文件名:rotatable\u info.xml
):
似乎是一只虫子vectorDrawables.useSupportLibrary=true
解决了该问题
有关详细信息,请参阅下页的“Vector drawables向后兼容解决方案”部分:
@pskink;你的意思是使用android.support.v7.widget.AppCompatImageView
和app:srccomat
而不是ImageView
和android:src
?这些变化没有什么不同。@pskink;From:为了在XML文件中引用VectorDrawableCompat,可以在AppCompat库的ImageButton或ImageView中使用app:srccomat属性。//我在安卓6.0上进行了测试。
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360"
android:drawable="@drawable/ic_info_black_24dp" >
</rotate>
<LinearLayout android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<ImageView style="@style/style" android:id="@+id/ImageView00" />
<ImageView style="@style/style" android:id="@+id/ImageView01" />
<ImageView style="@style/style" android:id="@+id/ImageView02" />
...
<ImageView style="@style/style" android:id="@+id/ImageView19" />
</LinearLayout>
<style name="style">
<item name="android:layout_width">32dp</item>
<item name="android:layout_height">32dp</item>
<item name="android:src">@drawable/rotatable_info</item>
</style>
int n = -550;
((RotateDrawable) this.<ImageView>findViewById(R.id.ImageView00).getDrawable()).mutate().setLevel(n+=550);
((RotateDrawable) this.<ImageView>findViewById(R.id.ImageView01).getDrawable()).mutate().setLevel(n+=550);
...
((RotateDrawable) this.<ImageView>findViewById(R.id.ImageView18).getDrawable()).mutate().setLevel(n+=550);
((RotateDrawable) this.<ImageView>findViewById(R.id.ImageView19).getDrawable()).mutate().setLevel(n+=550);
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z"/>
</vector>