I want to share background animation in profile image.
Lets we start animation….Profile background animation just like a  other application.
animation

* First create a new project “MyAnimation”
* Than, we create a new folder in rec folder “anim”
we store our all animation file in “anim folder”.

 

create “zoom.xml” file in anim folder.

<code language=”xml”>

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale
        android:duration="10000"
        android:fromXScale="1.5"
        android:fromYScale="1.5"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="2.0"
        android:toYScale="2.0"
        android:repeatMode="reverse"
        android:repeatCount="infinite">
    </scale>
</set>

<code>

Create a new XML file in Layout folder name is “activity_profileView.xml”
and set the image in backgound view and profile view.

<code language=”xml”>

<RelativeLayout 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" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
    android:background="#000000">
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <RelativeLayout
            android:id="@+id/relative"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/profile"
            android:alpha="0.6">

        </RelativeLayout>
        <ImageView
            android:layout_width="90dp"
            android:layout_height="90dp"
            android:src="@drawable/profile"
         />

    </FrameLayout>



</RelativeLayout>

</code>

 

 

Then,Open mainactivity.java and write the code..

RelativeLayout relativeLayout=(RelativeLayout)findViewById(R.id.relative);
Animation animation= AnimationUtils.loadAnimation(getApplicationContext(),R.anim.zoom);
relativeLayout.startAnimation(animation);

Result:

animation_example

Advertisements