How to set Horizontal flip animation in android

Let's see how to set Horizontal flip animation in android.



Create a xml file in anim folder. Then name it flip_h.






flip_h.xml


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale
        android:interpolator="@android:anim/accelerate_decelerate_interpolator"
        android:fromXScale="1.0"
        android:toXScale="-1.0"
        android:fromYScale="1.0"
        android:toYScale="1.0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:duration="400"
        android:repeatMode="reverse"
        android:repeatCount="24"

     />
</set>

Xscale  is  horizontal . We want to animate it horizontally that's why set it from 1 to -1
Yscale is vertical.

We can reduce duration for fast and increase to load slowly.
repeatCount will repeat the animation as you set the value. Here I set it 24. As a result it will repeat 24 times.


duration  is the Amount of time for the animation to run which set in millisecond.






activity_main.xml


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.hp.symonapps.MainActivity"
    android:orientation="vertical"
    android:gravity="center">


    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/iv"
        android:src="@drawable/ss2"/>


</LinearLayout>



MainActivity.java


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.example.hp.symonapps;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;


public class MainActivity extends AppCompatActivity {



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


          ImageView iv=(ImageView)findViewById(R.id.iv); //cast the iv imageView button
          Animation anim=AnimationUtils.loadAnimation(MainActivity.this, R.anim.flip_h);
          iv.setAnimation(anim);




    } //onCreate end


}

Comments

  1. VERY NICE INFORMATION THANKS FOR SHARING AND DOWNLOAD FREE NOVEL PDF BOOK FREE CLICK BELOW.
    romantic urdu novels pdf free download
    new urdu novels 2019 pdf download
    full romantic urdu novels
    urdu novels free download maha malik
    romantic urdu novels pdf free download 2020
    urdu novels free download umera ahmed
    pakistani urdu novel
    famous urdu novels free download
    romantic urdu novels pdf free download 2018
    pakistani urdu novel
    pakistani urdu novel
    urdu novel collection download
    forced marriage urdu romantic novels

    full romantic urdu novels
    bin roye ansoo (novel)
    humsafar novel
    urdu novels free download maha malik
    mata-e-jaan hai tu (novel)
    bano novel
    urdu novels free download umera ahmed
    romantic urdu novels pdf free download
    free download urdu pdf books and novels
    urdu novels name
    urdu novels blogspot
    urdu novels by famous writers
    m ilyas novels pdf free download
    aur hamal thehr gaya novel
    historical urdu books
    ek awara ki khatir novel
    history books in urdu free download pdf
    novel urdu books
    hikmat books in urdu free download
    best urdu books pdf free
    urdu magazines pdf free download
    best urdu books of all time
    waba ke dino mein mohabbat pdf
    urdu novels, free download by farhat ishtiaq
    best urdu novels pakistani writers
    best selling books in urdu
    nikah e mohabbat novel
    ziddi junoon full novel pdf download
    urdu novel zidd (junoon ki inteha)
    junoon based urdu novel
    ziddi ishq novel
    neena khan novels list
    gandy novel in urdu pdf download
    badan bazar novel
    wehshi novel pdf download
    samay ka bandhan pdf free download
    bookspdfpoint blogspot
    romantic urdu novels pdf free download 2019

    ReplyDelete

Post a Comment