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()
            }
        }

 

相关推荐

  1. Android 3D翻转实现

    2024-05-09 15:36:06       12 阅读
  2. HTML/CSS实现3D翻转页面效果

    2024-05-09 15:36:06       39 阅读
  3. wpf 实现3D按钮

    2024-05-09 15:36:06       33 阅读
  4. python实现3D玫瑰花

    2024-05-09 15:36:06       33 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-05-09 15:36:06       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-05-09 15:36:06       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-05-09 15:36:06       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-05-09 15:36:06       20 阅读

热门阅读

  1. redux实现原理

    2024-05-09 15:36:06       13 阅读
  2. 算法精讲:冒泡排序

    2024-05-09 15:36:06       13 阅读
  3. C++类型与声明

    2024-05-09 15:36:06       14 阅读
  4. 每天一个数据分析题(三百一十三)-漏斗模型

    2024-05-09 15:36:06       16 阅读
  5. var, let, const 的区别

    2024-05-09 15:36:06       12 阅读
  6. poker(typescript版)

    2024-05-09 15:36:06       13 阅读