Wednesday, July 8, 2020

Custom Animation -XML

Make your Animation
Set your custom animation in view
First of all go to res create anim folder and the create animation reasorce file
in animation dericatory 
a blink animation code is:

<?xml version="1.0" encoding="utf-8"?>
<set 
    xmlns:android="http://schemas.android.com/apk/res/android">

   <alpha android:fromAlpha="0.0"
           android:toAlpha="1.0"
           android:interpolator="@android:anim/accelerate_decelerate_interpolator"
           android:duration="300"
           android:repeatMode="restart"
           android:repeatCount="0" />
</set>

a bounce animation code is:
<set 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true"
    android:interpolator="@android:anim/bounce_interpolator">
       <scale android:toXScale="1.0"
           android:fromYScale="0.0"
           android:toYScale="1.0"
           android:fromXScale="1.0"
           android:duration="1500"/>
</set>


in main activity
    val anim= AnimationUtils.loadAnimation(applicationContext,R.anim.blink)
    buttonView.startAnimation(anim)

1 comment:

Dilog Builder - Kotlin

Dialog Builder in Kotlin  Set your default dialog in MainActivity demo: After clicking any button you can show dialoug in  button.setOnClick...