【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>
関連記事
-
-
【android】言語・地域設定の取得
androidでは利用する言語と国名がjava.util.Localeのオブジェクトとして設定されて
-
-
【android】 setOnClickListener(false)が効かない
間違いその1 OnClickListenerが登録されているViewにsetClickable
-
-
【android】設定画面の作成
res/xml/preferences.xml <?xml version=&quo
-
-
【android】 adbコマンド集
●adbサービス起動 adb start-server ●adbサービス終了 adb
-
-
【android】リスト項目のmatch_parentが効かない
下記のようなリスト項目用のレイアウトを用意して、リストの右端にチェックボックスを置くようにしたのです
-
-
【andoid】ViewPagerを使う
1. layout.xmlにViewPagerを配置 2. PagerAdapter.jav
-
-
【android】ホーム画面や他のアプリの前面にViewを表示する。
WindowManagerのTYPE_SYSTEM_ALERTのレイヤーにViewを表示することで、
-
-
【android】サービスの実装
ダウンロードなどActivityに依存したくない大きなバックグラウンド処理や常駐プロセスを作りたい場
-
-
【android】処理時間を計測する
パフォーマンスのリファクタリングを行うには処理時間の計測がかかせません。 SDK標準のクラスを使っ
-
-
[android] モンキーテスト(Monkey Test)を実行する
最近テストの効率化に目覚めました。 モンキーテストは猿にアプリを渡してみてめちゃくちゃな操作をさせ