Kotlin 在科特林,有人知道如何在甲板上结合翻转和滑动吗?
用户应该首先翻转一张卡,看到背面,然后向左或向右滑动。有人知道如何在科特林组合翻转甲板和侧击吗 翻转甲板看起来像这样: 轻扫如下所示:Kotlin 在科特林,有人知道如何在甲板上结合翻转和滑动吗?,kotlin,combinations,swipe,flip,Kotlin,Combinations,Swipe,Flip,用户应该首先翻转一张卡,看到背面,然后向左或向右滑动。有人知道如何在科特林组合翻转甲板和侧击吗 翻转甲板看起来像这样: 轻扫如下所示: 提前感谢并致以亲切问候。我想在Kotlin为Android创建一个堆栈,其中: 其项目位于同一位置(无偏移)。例如,像Tinder。只需看到堆栈的第一个项目/图像 我想加上翻页,看看卡片的背面。像这样: 翻转后,我想用向左或向右滑动的方式取出卡 到目前为止,我有一个包含以下代码的堆栈: main活动 package com.example.stackvie
提前感谢并致以亲切问候。我想在Kotlin为Android创建一个堆栈,其中:
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
}
}
package com.example.stackview
导入androidx.appcompat.app.appcompat活动
导入android.os.Bundle
导入kotlinx.android.synthetic.main.activity\u main*
类MainActivity:AppCompatActivity(){
val itemList=listOf(R.drawable.ic_launcher_background,R.drawable.ic_launcher_background,R.drawable.ic_launcher_background)
重写创建时的乐趣(savedInstanceState:Bundle?){
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val stackAdapter=stackAdapter(此,项目列表)
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")
}
}
package com.example.stackview
导入android.content.Context
导入android.view.LayoutInflater
导入android.view.view
导入android.view.ViewGroup
导入android.widget.BaseAdapter
导入android.widget.ImageView
类StackAdapter(val-context:context,val-list:list):BaseAdapter(){
覆盖视图(位置:Int,转换视图:View?,父视图:ViewGroup?):视图{
val view=LayoutInflater.from(上下文)。充气(R.layout.item,父项,false)
val item=view.findViewById(R.id.image)作为ImageView
item.setImageResource(列表[位置])
返回视图
TODO(“尚未实施”)
}
覆盖趣味getItem(位置:Int):任意{
返回列表[位置]
TODO(“尚未实施”)
}
覆盖getItemId(位置:Int):长{
返回位置。toLong()
TODO(“尚未实施”)
}
重写fun getCount():Int{
返回列表。大小
TODO(“尚未实施”)
}
}
这是什么平台?(这个问题看起来更多的是关于用户界面,而不是关于Kotlin。)你说的平台是什么意思?TornadFX/JavaFX/Swing、Android、iOS、Xamarin、SWT、Qt、KWeb……答案将特定于你正在使用的用户界面平台,可能不是Kotlin语言。啊,明白了。它适用于Android平台。
<?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>