Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android xml bundle format doesn't recognize aapt properties

I have tried using Android xml bundle format with example provided in Android Docs, but Android Studio keeps saying that

'drawable' or 'animation' attribute should be defined (See the screenshot)

What can be done in this case to fix the error?

<!-- drawable\some_anim.xml-->
<animated-vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
    <vector
        android:width="64dp"
        android:height="64dp"
        android:viewportHeight="600"
        android:viewportWidth="600">
        <group
            android:name="rotationGroup"
            android:pivotX="300.0"
            android:pivotY="300.0"
            android:rotation="45.0">
            <path
                android:name="v"
                android:fillColor="#000000"
                android:pathData="M300,70 l 0,-70 70,70 0,0 -70,70z"/>
        </group>
    </vector>
</aapt:attr>

<target android:name="rotationGroup">
    <aapt:attr name="android:animation">
        <objectAnimator
            android:duration="6000"
            android:propertyName="rotation"
            android:valueFrom="0"
            android:valueTo="360"/>
    </aapt:attr>
</target>

<target android:name="v">
    <aapt:attr name="android:animation">
        <set>
            <objectAnimator
                android:duration="3000"
                android:propertyName="pathData"
                android:valueFrom="M300,70 l 0,-70 70,70 0,0 -70,70z"
                android:valueTo="M300,70 l 0,-70 70,0  0,140 -70,0 z"
                android:valueType="pathType"/>
        </set>
    </aapt:attr>
</target>

like image 448
arslancharyev31 Avatar asked Nov 08 '22 01:11

arslancharyev31


1 Answers

You have to add extra things in some of tags

at

<android vector add    android:drawable="">

and In target tags

    <target add android:animation="">

and lastly added prefix to some tags at

    <aapt android:name="android:animation">

this is whole code copy and paste it and then check:

<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/tools" android:drawable="@color/divider">
<aapt:attr android:name="android:drawable">
    <vector
        android:height="64dp"
        android:width="64dp"
        android:viewportHeight="600"
        android:viewportWidth="600" >
        <group
            android:name="rotationGroup"
            android:pivotX="300.0"
            android:pivotY="300.0"
            android:rotation="45.0" >
            <path
                android:name="v"
                android:fillColor="#000000"
                android:pathData="M300,70 l 0,-70 70,70 0,0 -70,70z" />
        </group>
    </vector>
</aapt:attr>

<target android:name="rotationGroup"
    android:animation="@android:anim/slide_out_right"> 
    <aapt:attr android:name="android:animation">
        <objectAnimator
            android:duration="6000"
            android:propertyName="rotation"
            android:valueFrom="0"
            android:valueTo="360" />
    </aapt:attr>
</target>

<target android:name="v"
    android:animation="@android:anim/cycle_interpolator">
    <aapt:attr android:name="android:animation">
        <set>
            <objectAnimator
                android:duration="3000"
                android:propertyName="pathData"
                android:valueFrom="M300,70 l 0,-70 70,70 0,0 -70,70z"
                android:valueTo="M300,70 l 0,-70 70,0  0,140 -70,0 z"
                android:valueType="pathType"/>
        </set>
    </aapt:attr>
</target>

like image 121
vicky Avatar answered Nov 15 '22 06:11

vicky