- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我使用 android.support.v4
override fun onClick(movie: Movie, poster: ImageView, name: TextView) {
val intent = Intent(activity, DetailActivity::class.java).apply {
putExtras(Bundle().apply {
putParcelable(EXTRA_MOVIE, movie)
})
}
val activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(
requireActivity(),
// Now we provide a list of Pair items which contain the view we can transitioning
// from, and the name of the view it is transitioning to, in the launched activity
Pair<View, String?>(poster, ViewCompat.getTransitionName(poster)),
Pair<View, String?>(name, ViewCompat.getTransitionName(name)))
// Now we can start the Activity, providing the activity options as a bundle
ActivityCompat.startActivity(requireContext(), intent, activityOptions.toBundle())
}
现在我想迁移到 androidx.core.app
。出于某种原因,它在 makeSceneTransitionAnimation
上显示错误,指出 不能使用提供的参数调用以下函数
。
有人遇到过这样的问题吗?
最佳答案
对我来说,它是这样工作的:
//Watchout about this import, it is important!!
import androidx.core.util.Pair
//onCreate code avoided here
val testView = ImageView(this)
val activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(
MainActivity.this,
Pair<View, String>(testView, "hi1"),
Pair<View, String>(testView, "hi2")
)
// ... startActivity code here
使用这两个依赖项:
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.1'
关于android - makeSceneTransitionAnimation 在使用 AndroidX 时显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54425933/
我正在尝试将元素从 GridView 过渡到新的 Activity。 我得到了下面的项目点击事件, mGridView.setOnItemClickListener(new OnItemClickLi
我正在创建一个带有时间轴的 Android 应用程序。我使用 ListView 来创建时间轴效果。当我单击 ListViewItem 时,我使用 makeSceneTransitionAnimatio
我正在为 API 级别 20+ 的设备进行场景转换。它工作正常,但我想设置自定义持续时间来进行转换。可能吗?? 我的代码: ActivityOptionsCompat options =
我目前正在尝试在我的 FAB 和另一个 Activity 之间创建一个循环过渡。 根据我在文档中的理解,我应该以与此类似的方式使用 makeSceneTransitionAnimation: publ
我有一个 rippleDrawable 用作 LinearLayout 的背景: 我想在布局的 onClick 上启动一个新 Activity 。当我执行 startActivity() 时,涟漪效
Android L 引入了一项新的动画功能:在不同 Activity 中的相似 View 之间进行动画处理。已记录 here . 我尝试过使用 ActivityOptions.makeSceneTra
当我使用 android.support.v4 时,我有以下方法可以正常工作 override fun onClick(movie: Movie, poster: ImageView, name: T
我有两个 Activity 和它们之间的幻灯片过渡。很简单。但是,无论出于何种原因,ActivityOptions.makeSceneTransitionAnimation(Activity) 似乎都
这是我的 Activity 过渡动画的 Kotlin 代码 val p1 = Pair.create(imageViewhospitals, "hospitals") val p2 =
我正在尝试使用来自回收器适配器的共享元素转换来启动一项 Activity 。 这是 fragment :- @Override public void onBindViewHolder(final V
我是一名优秀的程序员,十分优秀!