Android Studio Gradient animation kotlin
Colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
<color name="colorTransparent">#00FFFFFF</color>
<color name="colorGradientStart">#D9ff43</color>
<color name="colorGradientCenter">#f67831</color>
<color name="colorGradientend">#ff1493</color>
<color name="colorStripeStart">#1eff0e5a</color>
<color name="colorStripetend">#1effd640</color>
</resources>
Android Studio Design Animation
Style.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
Android Studio Design Animation
Gradientsstart.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:type="linear"
android:angle="315"
android:startColor="@color/colorGradientStart"
android:centerColor="@color/colorGradientCenter"
android:endColor="@color/colorGradientend"/>
</shape>
Android Studio Design Animation
Gradientscenter.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:type="linear"
android:angle="315"
android:startColor="@color/colorGradientCenter"
android:centerColor="@color/colorGradientend"
android:endColor="@color/colorGradientStart"/>
</shape>
Android Studio Design Animation
Gradientend.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:type="linear"
android:angle="315"
android:startColor="@color/colorGradientend"
android:centerColor="@color/colorGradientStart"
android:endColor="@color/colorGradientCenter"/>
</shape>
Android Studio Design Animation
Animationgradientlist.xml
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/gradient_start"
android:duration="5000"/>
<item
android:drawable="@drawable/gradient_center"
android:duration="5000"/>
<item
android:drawable="@drawable/gradient_end"
android:duration="5000"/>
</animation-list>
Android Studio Design Animation
Activity_Main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/gradient_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/animationgradientlist"
tools:context=".design8part15">
</androidx.constraintlayout.widget.ConstraintLayout>
Android Studio Design Animation
Main_Activity.kt
package com.designapp
import android.graphics.drawable.AnimationDrawable
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_design8part15.*
class design8part15 : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_design8part15)
val animationDrawable = gradient_layout.background as AnimationDrawable
animationDrawable.setEnterFadeDuration(10)
animationDrawable.setExitFadeDuration(5000)
animationDrawable.start()
}
}
Mantul
ReplyDelete