有人知道如何在科特林的甲板上组合翻转和滑动吗



用户应该首先翻转卡片并看到背面,然后向左或向右滑动。有人知道如何在Kotlin组合翻盖和滑动吗?

Flip deck如下所示:https://stuff.mit.edu/afs/sipb/project/android/docs/training/animation/cardflip.html

滑动方式如下所示:https://github.com/yuyakaido/CardStackView

提前感谢并致以亲切的问候。

我想在Kotlin中为Android创建一个堆栈:

  1. 其项目位于相同位置(无偏移(。例如,像Tinder。人们只看到堆栈的第一个项目/图像。

  2. 我想添加flip并查看卡的背面。像这样:https://stuff.mit.edu/afs/sipb/project/android/docs/training/animation/cardflip.html

  3. 翻转后,我想向左或向右滑动取出卡片。

到目前为止,我有一个包含以下代码的堆栈:

主要活动

package com.example.stackview
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
val itemList = listOf<Int>(R.drawable.ic_launcher_background, R.drawable.ic_launcher_background, R.drawable.ic_launcher_background)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val stackAdapter = StackAdapter (this, itemList)
stack_view.adapter = stackAdapter
}
}

StackAdapter

package com.example.stackview
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.ImageView
class StackAdapter(val context: Context, val list: List<Int>): BaseAdapter(){
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
val view = LayoutInflater.from(context).inflate(R.layout.item, parent, false)
val item = view.findViewById<ImageView>(R.id.image) as ImageView
item.setImageResource(list[position])
return view
TODO("Not yet implemented")
}
override fun getItem(position: Int): Any {
return list[position]
TODO("Not yet implemented")
}
override fun getItemId(position: Int): Long {
return position.toLong()
TODO("Not yet implemented")
}
override fun getCount(): Int {
return list.size
TODO("Not yet implemented")
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="horizontal">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<StackView
android:id="@+id/stack_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:loopViews="true"
android:animateLayoutChanges="true"/>
</FrameLayout>
</LinearLayout>

最新更新