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()
            }
        }
相关推荐
w***42414 小时前
【mysql部署】在ubuntu22.04上安装和配置mysql教程
android·mysql·adb
e***753914 小时前
MySQL错误-this is incompatible with sql_mode=only_full_group_by完美解决方案
android·sql·mysql
道路与代码之旅14 小时前
“变量也能是函数?——论 Kotlin 中那些会说话的变量,以及它们如何让代码少说废话”
android·开发语言·kotlin
x***010615 小时前
Mysql之主从复制
android·数据库·mysql
千里马学框架15 小时前
wms开发常用调试开发技巧之WMShell的实用命令
android·framework·wms·安卓framework开发·systemui·proto·wmshell
龙之叶15 小时前
MT8766平台Android 12系统ESIM功能实现指南
android
诸神黄昏EX15 小时前
Android Qualcomm Diag
android
hy156878615 小时前
Flink 延时数据处理
android·java·flink
TeleostNaCl16 小时前
Android TV | 一种不跳出应用指定页面的类 Monkey 的 Android TV 压测脚本
android·经验分享·压力测试
k***082916 小时前
mysql中general_log日志详解
android·数据库·mysql