Ever since convert ConstraintLayout to MotionLayout handler.postdelayed not work
These are my codes
Layout
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/jjjk"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
app:layoutDescription="@xml/chapter2_scene2">
<ImageView
android:id="@+id/image_view"
android:layout_width="0dp"
android:layout_height="0dp"
android:src="@drawable/ic_launcher_background"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent="0.3"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.5" />
</androidx.constraintlayout.motion.widget.MotionLayout>
Java
Handler mHandler = new Handler();
mHandler.postDelayed(new Runnable() {
public void run() {
imageView.setVisibility(View.VISIBLE);
}
}, 100);
But it works if I write the imageView.setVisibility(View.VISIBLE);
outside the handler.postdelayed
The problem is that I android:visibility="gone"
the image view
If I use the android:visibility="invisible"
, there is no problem
But I want to delay the display of larger images with this method so that the page loads well
What is the problem?