你好,我是新的过渡。在过渡期间,您可以看到隐藏的白色背景。

练习A->练习B
(在A中设置动画)
private fun setupWindowAnimations() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// A (general activity) --> B ((this , detail activity))
val slide = Slide(Gravity.LEFT)
slide.duration = 500
window.enterTransition = slide
// A (general activity) <-- B ((this, detail activity))
val fade = Fade()
fade.duration = 1000
window.returnTransition = fade
}(viewHolder-A中的动画触发器)
override fun onClick(view: View?) {
if (view != null) {
val intent: Intent = Intent(view.context, DisksActivity::class.java)
val bundle: Bundle = Bundle()
bundle.putString(view.context.getString(R.string.EXTRA_DISK_TITLE), itemView.tag.toString())
intent.putExtras(bundle)
val sharedView: View = itemView.findViewById(R.id.cd_room_title)
val transitionName: String = view.context.getString(R.string.transition_disk_name_title)
val options = ActivityOptionsCompat.makeSceneTransitionAnimation(
view.context as Activity, sharedView, transitionName)
view.context.startActivity(intent,options.toBundle())
}
}(在B中设置动画)
private fun setupWindowAnimations() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// A (general activity) --> B ((this , detail activity))
val slide = Slide(Gravity.LEFT)
slide.duration = 500
window.enterTransition = slide
// A (general activity) <-- B ((this, detail activity))
val fade = Fade()
fade.duration = 1000
window.returnTransition = fade
}
}(两者的主布局)
<RelativeLayout 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"
android:background="@drawable/rock_background"
tools:context=".presentation.MainActivity">

如何在过渡过程中设置背景?或者,您是否知道一些解决方法?
谢谢!
发布于 2018-07-30 02:11:57
使用第二个活动的主题设置windowBackground可能会有所帮助。
创建一个可绘制的,并将其命名为background.xml,以设置为第二个带有显示的活动的窗口背景,直到加载布局:-
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/colorPrimary" />
</layer-list>下一步是为styles.xml中的第二个活动创建主题
<style name="Theme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/background</item>
</style>现在,通过在清单中的activity标记内设置android:theme="@style/Theme"属性来设置第二个活动的主题。
希望这能有所帮助。
https://stackoverflow.com/questions/51582924
复制相似问题