AndroidStudio:Explode动画不';当我在xml中为根布局设置背景色时,它不起作用
我不知道这是一个bug还是我犯了一些错误,但当我在打开AndroidStudio:Explode动画不';当我在xml中为根布局设置背景色时,它不起作用,android,xml,android-layout,kotlin,android-animation,Android,Xml,Android Layout,Kotlin,Android Animation,我不知道这是一个bug还是我犯了一些错误,但当我在打开活动时设置分解动画时,它会像一个幻灯片动画一样从上到下进行动画制作。我做了一些尝试和错误,结果表明,当我在xml文件的根布局中使用自定义背景颜色时,会发生这种意外行为。当我移除背景颜色时,一切正常 有人能告诉我这里发生了什么吗???因为在根布局中设置背景颜色对我来说很重要 下面是我的xml代码示例: <?xml version="1.0" encoding="utf-8"?> <and
活动时设置分解
动画
时,它会像一个幻灯片
动画一样从上到下进行动画制作。我做了一些尝试和错误,结果表明,当我在xml
文件的根布局中使用自定义背景
颜色时,会发生这种意外行为。当我移除背景
颜色时,一切正常
有人能告诉我这里发生了什么吗???因为在根布局中设置背景
颜色对我来说很重要
下面是我的xml
代码示例:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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="#000000" // This causes the unexpected behavior.
tools:context=".ExplodeActivity">
<ImageView
android:id="@+id/imageView2"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_marginTop="100dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/b" />
<Button
android:id="@+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
以下是前一个活动的代码,它负责启动活动
:
val options = ActivityOptions.makeSceneTransitionAnimation(this).toBundle()
val intent = Intent(this, ExplodeActivity::class.java)
startActivity(intent, options)
有趣。你试过在Kotlin中设置背景色吗?我使用style.xml
中的@color/dt_main_background
设置了背景色,现在效果很好。很好,那么您最好在这里回答自己的问题。你试过在Kotlin中设置背景色吗?我使用style.xml
中的@color/dt_main_background
设置了背景色,现在效果很好。很好,那么您最好在这里回答自己的问题
val options = ActivityOptions.makeSceneTransitionAnimation(this).toBundle()
val intent = Intent(this, ExplodeActivity::class.java)
startActivity(intent, options)