• R/O
  • HTTP
  • SSH
  • HTTPS

提交

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

development


Commit MetaInfo

修訂670bde6ff0581a64de1edf2cb4c09e2f3aaff54d (tree)
時間2009-03-26 07:05:49
作者Jean-Baptiste Queru <>
CommiterThe Android Open Source Project

Log Message

Automated import from //branches/master/...@142574,142574

Change Summary

差異

--- a/samples/ApiDemos/AndroidManifest.xml
+++ b/samples/ApiDemos/AndroidManifest.xml
@@ -1106,6 +1106,13 @@
11061106 </intent-filter>
11071107 </activity>
11081108
1109+ <activity android:name=".view.Animation3" android:label="Views/Animation/Interpolators">
1110+ <intent-filter>
1111+ <action android:name="android.intent.action.MAIN" />
1112+ <category android:name="android.intent.category.SAMPLE_CODE" />
1113+ </intent-filter>
1114+ </activity>
1115+
11091116 <activity android:name=".view.LayoutAnimation1" android:label="Views/Layout Animation/1. Grid Fade">
11101117 <intent-filter>
11111118 <action android:name="android.intent.action.MAIN" />
--- /dev/null
+++ b/samples/ApiDemos/res/layout/animation_3.xml
@@ -0,0 +1,44 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<!-- Copyright (C) 2009 The Android Open Source Project
3+
4+ Licensed under the Apache License, Version 2.0 (the "License");
5+ you may not use this file except in compliance with the License.
6+ You may obtain a copy of the License at
7+
8+ http://www.apache.org/licenses/LICENSE-2.0
9+
10+ Unless required by applicable law or agreed to in writing, software
11+ distributed under the License is distributed on an "AS IS" BASIS,
12+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ See the License for the specific language governing permissions and
14+ limitations under the License.
15+-->
16+
17+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
18+ android:orientation="vertical"
19+ android:padding="10dip"
20+ android:layout_width="fill_parent"
21+ android:layout_height="wrap_content"
22+ android:clipToPadding="false">
23+
24+ <TextView
25+ android:id="@+id/target"
26+ android:layout_width="wrap_content"
27+ android:layout_height="wrap_content"
28+ android:textSize="26sp"
29+ android:text="@string/animation_3_text"/>
30+
31+ <TextView
32+ android:layout_width="fill_parent"
33+ android:layout_height="wrap_content"
34+ android:layout_marginTop="20dip"
35+ android:layout_marginBottom="5dip"
36+ android:text="@string/animation_2_instructions" />
37+
38+ <Spinner
39+ android:id="@+id/spinner"
40+ android:layout_width="fill_parent"
41+ android:layout_height="wrap_content" />
42+
43+</LinearLayout>
44+
--- a/samples/ApiDemos/res/values/strings.xml
+++ b/samples/ApiDemos/res/values/strings.xml
@@ -476,6 +476,7 @@
476476 <string name="animation_2_text_3">a chance to be better.</string>
477477 <string name="animation_2_text_4">— Albert Camus</string>
478478 <string name="animation_2_instructions">Select an animation:</string>
479+ <string name="animation_3_text">Interpolators</string>
479480 <string name="autocomplete_1_instructions">Type in the text field for auto-completion.</string>
480481 <string name="autocomplete_1_country">Country:</string>
481482 <string name="autocomplete_1_focus">Give me Focus</string>
--- /dev/null
+++ b/samples/ApiDemos/src/com/example/android/apis/view/Animation3.java
@@ -0,0 +1,101 @@
1+/*
2+ * Copyright (C) 2009 The Android Open Source Project
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+package com.example.android.apis.view;
18+
19+// Need the following import to get access to the app resources, since this
20+// class is in a sub-package.
21+import com.example.android.apis.R;
22+
23+import android.app.Activity;
24+import android.os.Bundle;
25+import android.view.View;
26+import android.view.animation.AnimationUtils;
27+import android.view.animation.Animation;
28+import android.view.animation.TranslateAnimation;
29+import android.widget.AdapterView;
30+import android.widget.ArrayAdapter;
31+import android.widget.Spinner;
32+
33+public class Animation3 extends Activity implements AdapterView.OnItemSelectedListener {
34+ private static final String[] INTERPOLATORS = {
35+ "Accelerate", "Decelerate", "Accelerate/Decelerate",
36+ "Anticipate", "Overshoot", "Anticipate/Overshoot",
37+ "Bounce"
38+ };
39+
40+ @Override
41+ public void onCreate(Bundle savedInstanceState) {
42+ super.onCreate(savedInstanceState);
43+ setContentView(R.layout.animation_3);
44+
45+ Spinner s = (Spinner) findViewById(R.id.spinner);
46+ ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
47+ android.R.layout.simple_spinner_item, INTERPOLATORS);
48+ adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
49+ s.setAdapter(adapter);
50+ s.setOnItemSelectedListener(this);
51+ }
52+
53+ public void onItemSelected(AdapterView parent, View v, int position, long id) {
54+ final View target = findViewById(R.id.target);
55+ final View targetParent = (View) target.getParent();
56+
57+ Animation a = new TranslateAnimation(0.0f,
58+ targetParent.getWidth() - target.getWidth() - targetParent.getPaddingLeft() -
59+ targetParent.getPaddingRight(), 0.0f, 0.0f);
60+ a.setDuration(1000);
61+ a.setStartOffset(300);
62+ a.setRepeatMode(Animation.RESTART);
63+ a.setRepeatCount(Animation.INFINITE);
64+
65+ switch (position) {
66+ case 0:
67+ a.setInterpolator(AnimationUtils.loadInterpolator(this,
68+ android.R.anim.accelerate_interpolator));
69+ break;
70+ case 1:
71+ a.setInterpolator(AnimationUtils.loadInterpolator(this,
72+ android.R.anim.decelerate_interpolator));
73+ break;
74+ case 2:
75+ a.setInterpolator(AnimationUtils.loadInterpolator(this,
76+ android.R.anim.accelerate_decelerate_interpolator));
77+ break;
78+ case 3:
79+ a.setInterpolator(AnimationUtils.loadInterpolator(this,
80+ android.R.anim.anticipate_interpolator));
81+ break;
82+ case 4:
83+ a.setInterpolator(AnimationUtils.loadInterpolator(this,
84+ android.R.anim.overshoot_interpolator));
85+ break;
86+ case 5:
87+ a.setInterpolator(AnimationUtils.loadInterpolator(this,
88+ android.R.anim.anticipate_overshoot_interpolator));
89+ break;
90+ case 6:
91+ a.setInterpolator(AnimationUtils.loadInterpolator(this,
92+ android.R.anim.bounce_interpolator));
93+ break;
94+ }
95+
96+ target.startAnimation(a);
97+ }
98+
99+ public void onNothingSelected(AdapterView parent) {
100+ }
101+}
\ No newline at end of file