groovy android { defaultConfig { vectorDrawables.useSupportLibrary = true } } dependencies { implementation 'com.android.support:appcompat-v7:28.0.0' } <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" app:srcCompat="@drawable/ic_heart" /> <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="#FF0000" android:pathData="M20.77,5.23c-1.61,-1.61 -3.75,-2.5 -6.01,-2.5c-2.26,0 -4.4,0.89 -6.01,2.5c-3.32,3.32 -3.32,8.68 0,12c1.62,1.61 3.75,2.5 6.01,2.5s4.39,-0.89 6.01,-2.5c3.32,-3.32 3.32,-8.68 0,-12m-2.77,10l-2,2l-2,-2c-1.45,1.45 -3.55,1.45 -5,0c-1.56,-1.56 -1.95,-3.84 -1,-5.81c0.94,-2.52 3.27,-4.19 5.83,-4.19c2.57,0 4.90,1.67 5.83,4.19c0.75,2.02 0.31,4.26 -1,5.81zM9,9l2,2l2,-2c1.33,-1.33 3.46,-1.33 4.79,0c1.32,1.33 1.32,3.47 0,4.8c-0.63,0.64 -1.46,0.97 -2.4,0.97s-1.77,-0.32 -2.4,-0.97c-1.32,-1.33 -1.32,-3.46 0,-4.8L9,9z" /> </vector> kotlin val heartImageView: ImageView = findViewById(R.id.heart_image_view) val animator = ObjectAnimator.ofFloat(heartImageView, "alpha", 0f, 1f) animator.repeatCount = ObjectAnimator.INFINITE animator.repeatMode = ObjectAnimator.REVERSE animator.duration = 1000 animator.start()


上一篇:
下一篇:
切换中文