안드로이드

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

    

 

class MainActivity

package kr.co.braverokmc.myframeanimation;

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

public class MainActivity extends AppCompatActivity {

    ImageView imageView1;
    LinearLayout container;

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

        imageView1=(ImageView)findViewById(R.id.imageView1);
        container=(LinearLayout)findViewById(R.id.container);

    }


    public void onClick(View v){
       Animation  scale = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.scale);
       final Animation translate=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.translate);


       scale.setAnimationListener(new Animation.AnimationListener() {
           @Override
           public void onAnimationStart(Animation animation) {

           }

           @Override
           public void onAnimationEnd(Animation animation) {
               // imageView1.startAnimation(translate);
               container.startAnimation(translate);
           }

           @Override
           public void onAnimationRepeat(Animation animation) {

           }
       });

       // imageView1.startAnimation(scale);
        container.startAnimation(scale);
    }




}

 

R.layout.activity_main

<?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:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@android:color/holo_green_light"
    >

    <ImageView
        android:layout_margin="100dp"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:text="Hello World!"
        android:src="@drawable/a1"
        android:id="@+id/imageView1"
        android:layout_gravity="center_horizontal"
        />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="시작"
        android:onClick="onClick"
        android:textAlignment="center"
        android:layout_gravity="center_horizontal"
        />


</LinearLayout>

 

scale.xml

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

    <!--확대-->
    <scale
        android:fromXScale="1.0"
        android:fromYScale="1.0"
        android:toXScale="2.0"
        android:toYScale="2.0"
        android:duration="1500"
        android:pivotX="50%"
        android:pivotY="50%"
        >

    </scale>


    <!--축소-->
    <scale
        android:fromXScale="1.0"
        android:fromYScale="1.0"
        android:toXScale="0.5"
        android:toYScale="0.5"
        android:duration="1500"
        android:pivotX="50%"
        android:pivotY="50%"
        android:startOffset="1500"
        >

        <!--
            startOffset : 앞에 있는 애니메이션 1.5후 실행

        -->
    </scale>



</set>

 

 

 

translate.xml

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

    <translate
        android:fromXDelta="0%p"
        android:toXDelta="100%p"
        android:duration="1500"
        android:fillAfter="true"
        >

    </translate>



</set>

 

 

 

 

 

91강

 

92강

 

 

 

android

 

about author

PHRASE

Level 60  머나먼나라

국민의 수가 적거나 물질이 적다고 걱정할 필요가 없다. 그보다는 모두가 불평등하다 부당하다고 하는 불만을 지니는 것을 걱정해야 한다. 따라서 정치는 공평해야 하는 것이다. -논어

댓글 ( 4)

댓글 남기기

작성