Automated import from //branches/donutburger/...@142465,142465
This commit is contained in:
committed by
The Android Open Source Project
parent
0bd19e8b8b
commit
02e8d006b0
@@ -1106,6 +1106,13 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".view.Animation3" android:label="Views/Animation/Interpolators">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity android:name=".view.LayoutAnimation1" android:label="Views/Layout Animation/1. Grid Fade">
|
<activity android:name=".view.LayoutAnimation1" android:label="Views/Layout Animation/1. Grid Fade">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|||||||
44
samples/ApiDemos/res/layout/animation_3.xml
Normal file
44
samples/ApiDemos/res/layout/animation_3.xml
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2009 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="10dip"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:clipToPadding="false">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/target"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="26sp"
|
||||||
|
android:text="@string/animation_3_text"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="20dip"
|
||||||
|
android:layout_marginBottom="5dip"
|
||||||
|
android:text="@string/animation_2_instructions" />
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/spinner"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
@@ -476,6 +476,7 @@
|
|||||||
<string name="animation_2_text_3">a chance to be better.</string>
|
<string name="animation_2_text_3">a chance to be better.</string>
|
||||||
<string name="animation_2_text_4">— Albert Camus</string>
|
<string name="animation_2_text_4">— Albert Camus</string>
|
||||||
<string name="animation_2_instructions">Select an animation:</string>
|
<string name="animation_2_instructions">Select an animation:</string>
|
||||||
|
<string name="animation_3_text">Interpolators</string>
|
||||||
<string name="autocomplete_1_instructions">Type in the text field for auto-completion.</string>
|
<string name="autocomplete_1_instructions">Type in the text field for auto-completion.</string>
|
||||||
<string name="autocomplete_1_country">Country:</string>
|
<string name="autocomplete_1_country">Country:</string>
|
||||||
<string name="autocomplete_1_focus">Give me Focus</string>
|
<string name="autocomplete_1_focus">Give me Focus</string>
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2009 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.example.android.apis.view;
|
||||||
|
|
||||||
|
// Need the following import to get access to the app resources, since this
|
||||||
|
// class is in a sub-package.
|
||||||
|
import com.example.android.apis.R;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.animation.AnimationUtils;
|
||||||
|
import android.view.animation.Animation;
|
||||||
|
import android.view.animation.TranslateAnimation;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
public class Animation3 extends Activity implements AdapterView.OnItemSelectedListener {
|
||||||
|
private static final String[] INTERPOLATORS = {
|
||||||
|
"Accelerate", "Decelerate", "Accelerate/Decelerate",
|
||||||
|
"Anticipate", "Overshoot", "Anticipate/Overshoot",
|
||||||
|
"Bounce"
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.animation_3);
|
||||||
|
|
||||||
|
Spinner s = (Spinner) findViewById(R.id.spinner);
|
||||||
|
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
|
||||||
|
android.R.layout.simple_spinner_item, INTERPOLATORS);
|
||||||
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
s.setAdapter(adapter);
|
||||||
|
s.setOnItemSelectedListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onItemSelected(AdapterView parent, View v, int position, long id) {
|
||||||
|
final View target = findViewById(R.id.target);
|
||||||
|
final View targetParent = (View) target.getParent();
|
||||||
|
|
||||||
|
Animation a = new TranslateAnimation(0.0f,
|
||||||
|
targetParent.getWidth() - target.getWidth() - targetParent.getPaddingLeft() -
|
||||||
|
targetParent.getPaddingRight(), 0.0f, 0.0f);
|
||||||
|
a.setDuration(1000);
|
||||||
|
a.setStartOffset(300);
|
||||||
|
a.setRepeatMode(Animation.RESTART);
|
||||||
|
a.setRepeatCount(Animation.INFINITE);
|
||||||
|
|
||||||
|
switch (position) {
|
||||||
|
case 0:
|
||||||
|
a.setInterpolator(AnimationUtils.loadInterpolator(this,
|
||||||
|
android.R.anim.accelerate_interpolator));
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
a.setInterpolator(AnimationUtils.loadInterpolator(this,
|
||||||
|
android.R.anim.decelerate_interpolator));
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
a.setInterpolator(AnimationUtils.loadInterpolator(this,
|
||||||
|
android.R.anim.accelerate_decelerate_interpolator));
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
a.setInterpolator(AnimationUtils.loadInterpolator(this,
|
||||||
|
android.R.anim.anticipate_interpolator));
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
a.setInterpolator(AnimationUtils.loadInterpolator(this,
|
||||||
|
android.R.anim.overshoot_interpolator));
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
a.setInterpolator(AnimationUtils.loadInterpolator(this,
|
||||||
|
android.R.anim.anticipate_overshoot_interpolator));
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
a.setInterpolator(AnimationUtils.loadInterpolator(this,
|
||||||
|
android.R.anim.bounce_interpolator));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
target.startAnimation(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onNothingSelected(AdapterView parent) {
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user