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()
            }
        }
相关推荐
2501_940094023 小时前
NDS模拟器安卓版 melonDS模拟器 汉化中文版 NDS BIOS和固件+NDS游戏和详细的使用教程
android·游戏
枫子有风5 小时前
Go语言流程控制
android·java·golang
杨筱毅6 小时前
【底层机制】ART虚拟机深度解析:Android运行时的架构革命
android·架构·底层机制
某空m6 小时前
【Android】活动的生命周期、启动模式及标记位
android
WAsbry7 小时前
InputConnection机制与跨进程文本操作的工程实践
android·linux
WAsbry7 小时前
Android输入法框架的Binder通信机制剖析
android
WAsbry7 小时前
从一个Bug看Android文本编辑的设计缺陷
android·linux
沐怡旸7 小时前
【底层机制】Android低内存管理机制深度解析
android
wuwu_q8 小时前
用通俗易懂 + Android 开发实战的方式讲解 Kotlin Flow 中的 filter 操作符
android·开发语言·kotlin
stevenzqzq10 小时前
Android Hilt 入门教程_注解汇总
android