*

【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】ホーム画面や他のアプリの前面にViewを表示する。

WindowManagerのTYPE_SYSTEM_ALERTのレイヤーにViewを表示することで、

記事を読む

no image

【android】ハードウェアキー入力を検出する

Activityを継承したクラスで下記を記述します。 public boolean

記事を読む

no image

【android】リソースからいろいろ取得する

リソースで定義したいろいろをコード内で呼び出す方法です。 レイアウト //リソースからレ

記事を読む

no image

【android】stringsリソースにパラメータを埋め込む

●strings.xml %n$x n : 引数に渡す際の順番。n番目の引数。 x

記事を読む

no image

【android】サービスの実装

ダウンロードなどActivityに依存したくない大きなバックグラウンド処理や常駐プロセスを作りたい場

記事を読む

no image

【android】非同期処理

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

記事を読む

no image

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

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

記事を読む

no image

【android】標準の設定画面を作る

設定画面のテンプレートです。 検索一発クンのコードから抜粋しました。 チェックボックス、リス

記事を読む

no image

【android】 adbコマンド集

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

記事を読む

no image

【android】バイブレーションを使う

必要なファイル MyApp.manifest MyApp.java MyApp.m

記事を読む

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 ↑