*

【android】アニメーション

公開日: : 最終更新日:2012/06/22 android

Viewにアニメーションを付加する方法です。

目次

アニメーションの実行

description

/*
@param R.anim.motion_name
*/

//アニメーション
Animation animation= AnimationUtils.loadAnimation(act, R.anim.motion_name);
animation.setFillAfter(true);   //終了後を保持
animation.setFillEnabled(true);
animation.setAnimationListener(new AnimationListener() {
	public void onAnimationStart(Animation animation) {
	}
	
	public void onAnimationRepeat(Animation animation) {
	}
	
	public void onAnimationEnd(Animation animation) {
	}
});
view.startAnimation(animation);
 
 

座標

res/anim/motion_name.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/decelerate_interpolator">
    <translate
        android:fromXDelta="0.0"
        android:toXDelta="0.0"
        android:fromYDelta="-100"
        android:toYDelta="0.0"
        android:duration="200"
        android:fillAfter="true"
        android:fillEnabled="true"
        />
</set>

透明度

res/anim/motion_name.xml

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

	<alpha
	    android:fromAlpha="float"
	    android:toAlpha="float" />

</set>

角度

res/anim/motion_name.xml

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

	<rotate
	    android:fromDegrees="float"
	    android:toDegrees="float"
	    android:pivotX="float"
	    android:pivotY="float" />

</set>

大きさ

res/anim/motion_name.xml

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

	<scale
	    android:fromXScale="float"
	    android:toXScale="float"
	    android:fromYScale="float"
	    android:toYScale="float"
	    android:pivotX="float"
	    android:pivotY="float" />

</set>

複合

res/anim/motion_name.xml

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

	<alpha
	    android:fromAlpha="float"
	    android:toAlpha="float" />


	<scale
	    android:fromXScale="float"
	    android:toXScale="float"
	    android:fromYScale="float"
	    android:toYScale="float"
	    android:pivotX="float"
	    android:pivotY="float" />

</set>

関連記事

no image

【android】 setOnClickListener(false)が効かない

間違いその1 OnClickListenerが登録されているViewにsetClickable

記事を読む

no image

ダイアログを表示する

カスタムアラートダイアログ private void showCustomAlert(A

記事を読む

no image

【android】任意のスレッドで処理を行う

非UIスレッドでUIを操作したい場合に、任意の処理をUIスレッド上で実行する。 目次

記事を読む

no image

【android】IMEの表示/非表示

//IMEを閉じる InputMethodManager inputMethodManager

記事を読む

no image

【android】 年月だけのDatePicker

final DatePicker datePicker = new DatePicker(sel

記事を読む

no image

[android] モンキーテスト(Monkey Test)を実行する

最近テストの効率化に目覚めました。 モンキーテストは猿にアプリを渡してみてめちゃくちゃな操作をさせ

記事を読む

no image

【android】非同期処理

Androidで非同期処理、マルチスレッドを処理するスニペット。 AndroidのスレッドはUIス

記事を読む

no image

【android】 adbコマンド集

●adbサービス起動 adb start-server ●adbサービス終了 adb

記事を読む

no image

【android】アプリのバージョン情報を取得する

int versionCode = -1; String versionName = &quo

記事を読む

no image

【android】言語・地域設定の取得

androidでは利用する言語と国名がjava.util.Localeのオブジェクトとして設定されて

記事を読む

Message

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

次のHTML タグと属性が使えます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

no image
知らないと損をする6つのライセンスまとめ

オープンソースやフリーウェア、フリー素材などが巷に溢れ、それらを利用す

no image
ガリレオ:ニュースブラウザをリリースしました。

概要 ガリレオはニュースを読んだり、検索する機能に特化したブラウザア

no image
【android】Activityとプロセスのライフサイクル

またもやライフサイクル周りでハマったのですが、Androidのライフサ

→もっと見る

PAGE TOP ↑