I'm trying to use carousel widget in motionlayout for making OnBoardActivity. I'm create three layout contain first, second and third layour. Then I create on_board_activity layout. This is my code:
<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutDescription="@xml/activity_on_board_scene">
<include
android:id="@+id/first"
layout="@layout/first_intro"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<include
android:id="@+id/second"
layout="@layout/second_intro"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<include
android:id="@+id/third"
layout="@layout/third_intro"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<androidx.constraintlayout.helper.widget.Carousel
android:id="@+id/carousel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:carousel_backwardTransition="@+id/backward"
app:carousel_firstView="@+id/second"
app:carousel_forwardTransition="@+id/forward"
app:carousel_infinite="true"
app:carousel_nextState="@+id/next"
app:carousel_previousState="@+id/previous"
app:constraint_referenced_ids="first,second, third" />
</androidx.constraintlayout.motion.widget.MotionLayout>
I create file activity_on_board_scene.xml, too. But I can't populate view in kotlin file. How can I do that? What do I need for program run ok?
override fun populate(view: View, index: Int) {
// need to implement this to populate the view at the given index
if (view is ConstraintLayout){
//how can I do that?
}
}