Professional Documents
Culture Documents
Assignment # 4
First type of animation:
MainActivity.kt
package com.Addi _assignment
import android.graphics.drawable.AnimatedImageDrawable
import android.graphics.drawable.AnimationDrawable
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.ImageView
var image=findViewById<ImageView>(R.id.image)
a.setEnterFadeDuration(3000)
a.setExitFadeDuration(1000)
a.start()
}
}
Main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
android:background="@drawable/animation"
android:scaleType="fitXY"
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ImageView>
</LinearLayout>
Animation.xml
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/splash"
android:duration="2000">
</item>
<item
android:drawable="@drawable/image"
android:duration="2000">
</item>
<item
android:drawable="@drawable/delsplash"
android:duration="2000">
</item>
</animation-list>
MainActivity.kt
package com.Addi _assignment
import android.graphics.drawable.AnimatedImageDrawable
import android.graphics.drawable.AnimationDrawable
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.ImageView
var image=findViewById<ImageView>(R.id.image)
a.setEnterFadeDuration(3000)
a.setExitFadeDuration(1000)
a.start()
}
}
Main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
android:background="@drawable/animation"
android:scaleType="fitXY"
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ImageView>
</LinearLayout>
Animation.xml
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/color_one"
android:duration="2000">
</item>
<item
android:drawable="@drawable/color_two"
android:duration="2000">
</item>
<item
android:drawable="@drawable/color_three"
android:duration="2000">
</item>
</animation-list>
color_one.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#4f3333"
android:angle="90"
android:endColor="#f33f3f">
</gradient>
</shape>
color_two.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="90"
android:startColor="#f3ff3f"
android:endColor="#9a9a9a">
</gradient>
</shape>
color_three.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="90"
android:startColor="#d3f311"
android:endColor="#a9a9a9">
</gradient>
</shape>