bug修改 - 引导的手指需要加动画(顺着指的方向前后移动)

This commit is contained in:
renhaoting 2025-12-26 15:42:25 +08:00
parent 8a045117ea
commit 8559ac16c1
6 changed files with 91 additions and 9 deletions

View File

@ -0,0 +1,63 @@
package com.gamedog.vididin.widget
import android.animation.AnimatorSet
import android.animation.ObjectAnimator
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.animation.AnimationSet
import android.widget.LinearLayout
import com.ama.core.architecture.util.ResUtil.dp
import com.vididin.real.money.game.databinding.LayoutAnimImageviewBinding
import kotlin.math.min
class AnimImageView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : LinearLayout(context, attrs, defStyleAttr) {
private var mBinding: LayoutAnimImageviewBinding
private val animationFraction = 0.2f
private var animatorSet: AnimatorSet = AnimatorSet()
init {
mBinding = LayoutAnimImageviewBinding.inflate(LayoutInflater.from(context), this, true)
startAnim()
}
private fun startAnim() {
with(mBinding) {
// 1. move distance
/*val moveDistanceX = -min(ivImage.width, ivImage.height) * animationFraction
val moveDistanceY = -min(ivImage.width, ivImage.height) * animationFraction*/
val moveDistanceX = -20.dp
val moveDistanceY = -20.dp
// 2. x and y
val animatorX = ObjectAnimator.ofFloat(ivImage, "translationX", 0f, moveDistanceX.toFloat())
val animatorY = ObjectAnimator.ofFloat(ivImage, "translationY", 0f, moveDistanceY.toFloat())
animatorX.repeatMode = ObjectAnimator.REVERSE
animatorX.repeatCount = ObjectAnimator.INFINITE
animatorY.repeatMode = ObjectAnimator.REVERSE
animatorY.repeatCount = ObjectAnimator.INFINITE
// 3. set
animatorSet.playTogether(animatorX, animatorY)
animatorSet.duration = 600
animatorSet.start()
}
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
animatorSet.cancel()
}
}

View File

@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:clipChildren="false">
<androidx.appcompat.widget.AppCompatImageView <com.gamedog.vididin.widget.AnimImageView
android:id="@+id/tv_tips" android:id="@+id/tv_tips"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_gravity="right" android:layout_gravity="right"

View File

@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:clipChildren="false">
<androidx.appcompat.widget.AppCompatImageView <com.gamedog.vididin.widget.AnimImageView
android:id="@+id/tv_tips" android:id="@+id/tv_tips"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_gravity="left" android:layout_gravity="left"

View File

@ -3,7 +3,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatImageView <com.gamedog.vididin.widget.AnimImageView
android:id="@+id/tv_tips" android:id="@+id/tv_tips"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_gravity="right" android:layout_gravity="right"

View File

@ -3,13 +3,12 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatImageView <com.gamedog.vididin.widget.AnimImageView
android:id="@+id/tv_tips" android:id="@+id/tv_tips"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_gravity="right"
android:layout_marginLeft="100dp"
android:layout_height="70dp" android:layout_height="70dp"
android:src="@mipmap/guide_finger_b" /> android:layout_gravity="right"
android:layout_marginStart="100dp" />
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clipChildren="false"
android:clipToPadding="false"
android:paddingTop="20dp"
android:paddingStart="20dp"
>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/ivImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/guide_finger_b"
/>
</FrameLayout>