Android 3D翻转实现

一、引入依赖

复制代码
allprojects {
  repositories {
    jcenter()
    maven { url "https://jitpack.io" }
  }
}

dependencies {
	  implementation("com.github.githubwing:ThreeDLayout:1.0.0")
	}

二、xml使用

复制代码
<?xml version="1.0" encoding="utf-8"?>
    <com.wingsofts.threedlayout.ThreeDLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/td_layout"
        android:background="@drawable/bg_trans_radius"
        android:layout_width="@dimen/dp_200"
        android:layout_height="@dimen/dp_200"
        >
    <ImageView
        android:id="@+id/modelPic"
        android:layout_width="@dimen/dp_200"
        android:layout_height="@dimen/dp_200"
        android:src="@drawable/location"
        android:layout_centerInParent="true"
        />
    </com.wingsofts.threedlayout.ThreeDLayout>

三、在RecyclerView中使用

可以实现指定位置item翻转

复制代码
        binding.chooseModel.setOnClickListener {
            val viewHolder = binding.rvContent.findViewHolderForAdapterPosition(choosePosition)
            if (viewHolder?.itemView != null) {
                val tdLayout: ThreeDLayout = viewHolder.itemView.findViewById(R.id.td_layout)
                tdLayout.startHorizontalAnimate()
                Thread {
                    try {
                        Thread.sleep(2500)
                    } catch (e: InterruptedException) {
                        e.printStackTrace()
                    }
                    runOnUiThread {
                        tdLayout.stopAnimate()
                        showToasts("翻转结束")
                    }
                }.start()
            }
        }
相关推荐
咋吃都不胖lyh3 小时前
SQL-多对多关系
android·mysql·数据分析
cyy2983 小时前
android 屏幕适配
android
Digitally5 小时前
如何通过 5 种有效方法同步 Android 和 Mac
android·macos
行墨7 小时前
Jetpack Compose 深入浅出(二)——基础组件Text
android
雨白8 小时前
深入理解协程的运作机制 —— 调度、挂起与性能
android·kotlin
沐怡旸8 小时前
【Android】Android系统体系结构
android
namehu9 小时前
React Native 应用性能分析与优化不完全指南
android·react native·ios
xqlily9 小时前
Kotlin:现代编程语言的革新者
android·开发语言·kotlin
HelloBan9 小时前
如何正确去掉SeekBar的Thumb和按压效果
android
木易 士心10 小时前
Android EventBus 源码解析:设计模式、原理与实现
android