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()
            }
        }
相关推荐
阿巴斯甜2 小时前
Android 报错:Zip file '/Users/lyy/develop/repoAndroidLapp/l-app-android-ble/app/bu
android
Kapaseker3 小时前
实战 Compose 中的 IntrinsicSize
android·kotlin
xq95274 小时前
Andorid Google 登录接入文档
android
黄林晴5 小时前
告别 Modifier 地狱,Compose 样式系统要变天了
android·android jetpack
冬奇Lab18 小时前
Android触摸事件分发、手势识别与输入优化实战
android·源码阅读
城东米粉儿21 小时前
Android MediaPlayer 笔记
android
Jony_21 小时前
Android 启动优化方案
android
阿巴斯甜21 小时前
Android studio 报错:Cause: error=86, Bad CPU type in executable
android
张小潇21 小时前
AOSP15 Input专题InputReader源码分析
android
_小马快跑_1 天前
Kotlin | 协程调度器选择:何时用CoroutineScope配置,何时用launch指定?
android