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()
            }
        }
相关推荐
极客小云几秒前
【深入理解 Android 中的 build.gradle 文件】
android·安卓·安全架构·安全性测试
Juskey iii9 分钟前
Android Studio Electric Eel | 2022.1.1 Patch 2 版本下载
android·ide·android studio
Android技术之家10 分钟前
2025年度Android行业总结:AI驱动生态重构,跨端融合开启新篇
android·人工智能·重构
洞见前行23 分钟前
Android第二代加固技术原理详解(附源码)
android
风清云淡_A29 分钟前
【JetCompose】入门教程实战基础案例01之显隐动画
android
2501_916007471 小时前
iPhone APP 性能测试怎么做,除了Instruments还有什么工具?
android·ios·小程序·https·uni-app·iphone·webview
2501_915106321 小时前
Windows 环境下有哪些可用的 iOS 上架工具, iOS 上架工具的使用方式
android·ios·小程序·https·uni-app·iphone·webview
冬奇Lab2 小时前
稳定性性能系列之六——Java异常与JE分析实战
android·性能优化·debug
爱装代码的小瓶子3 小时前
【c++进阶】c++11的魔法:从模板到可变模板.
android·开发语言·c++
lxysbly3 小时前
安卓MD模拟器下载指南2026
android