Merge "Add demo for rotation animation." into jb-mr2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
92a74bf534
@@ -244,6 +244,14 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".app.RotationAnimation"
|
||||||
|
android:label="@string/activity_rotation_animation">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity android:name=".app.ReorderTwo" />
|
<activity android:name=".app.ReorderTwo" />
|
||||||
<activity android:name=".app.ReorderThree" />
|
<activity android:name=".app.ReorderThree" />
|
||||||
<activity android:name=".app.ReorderFour" />
|
<activity android:name=".app.ReorderFour" />
|
||||||
|
|||||||
74
samples/ApiDemos/res/layout/rotation_animation.xml
Normal file
74
samples/ApiDemos/res/layout/rotation_animation.xml
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2013 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:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="#FFFFFFFF"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="@string/rotation_animation_description"
|
||||||
|
/>
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/windowFullscreen"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:text="@string/rotation_animation_fullscreen"
|
||||||
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:orientation="vertical"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="#FFFFFFFF"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="@string/rotation_animation_choices"
|
||||||
|
/>
|
||||||
|
<RadioGroup
|
||||||
|
android:id="@+id/rotation_radio_group"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:checkedButton="@+id/rotation_anim_selection"
|
||||||
|
>
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rotate"
|
||||||
|
android:checked="true"
|
||||||
|
android:text="@string/rotation_animation_rotate"
|
||||||
|
/>
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/crossfade"
|
||||||
|
android:layout_marginStart="6dp"
|
||||||
|
android:text="@string/rotation_animation_crossfade"
|
||||||
|
/>
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/jumpcut"
|
||||||
|
android:layout_marginStart="6dp"
|
||||||
|
android:text="@string/rotation_animation_jumpcut"
|
||||||
|
/>
|
||||||
|
</RadioGroup>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
@@ -387,6 +387,8 @@
|
|||||||
<string name="reorder_four_text">This is the last in a sequence of four Activities.</string>
|
<string name="reorder_four_text">This is the last in a sequence of four Activities.</string>
|
||||||
<string name="reorder_second_to_front">Bring the second in front</string>
|
<string name="reorder_second_to_front">Bring the second in front</string>
|
||||||
|
|
||||||
|
<string name ="activity_rotation_animation">App/Activity/Rotation Animation</string>
|
||||||
|
|
||||||
<string name="menu_from_xml_title">App/Menu/Inflate from XML</string>
|
<string name="menu_from_xml_title">App/Menu/Inflate from XML</string>
|
||||||
<string name="menu_from_xml_instructions_press_menu">Select a menu resource and press the menu key.</string>
|
<string name="menu_from_xml_instructions_press_menu">Select a menu resource and press the menu key.</string>
|
||||||
<string name="menu_from_xml_instructions_go_back">If you want to choose another menu resource, go back and re-run this activity.</string>
|
<string name="menu_from_xml_instructions_go_back">If you want to choose another menu resource, go back and re-run this activity.</string>
|
||||||
@@ -1156,6 +1158,16 @@
|
|||||||
<string name="relative_layout_2_instructions">Type here:</string>
|
<string name="relative_layout_2_instructions">Type here:</string>
|
||||||
<string name="relative_layout_2_ok">Ok</string>
|
<string name="relative_layout_2_ok">Ok</string>
|
||||||
<string name="relative_layout_2_cancel">Cancel</string>
|
<string name="relative_layout_2_cancel">Cancel</string>
|
||||||
|
<string name="rotation_animation_description">
|
||||||
|
Change the default rotation animation from rotating to fade or jumpcut.
|
||||||
|
Only works if FLAG_FULLSCREEN is set and there are no dialogs up.
|
||||||
|
Try rotating with and without the Power Off dialog visible.
|
||||||
|
</string>
|
||||||
|
<string name="rotation_animation_fullscreen">FULLSCREEN</string>
|
||||||
|
<string name="rotation_animation_choices">Rotation Animation:</string>
|
||||||
|
<string name="rotation_animation_rotate">ROTATE</string>
|
||||||
|
<string name="rotation_animation_crossfade">XFADE</string>
|
||||||
|
<string name="rotation_animation_jumpcut">JUMPCUT</string>
|
||||||
<string name="scroll_view_1_text_1">Text View 1</string>
|
<string name="scroll_view_1_text_1">Text View 1</string>
|
||||||
<string name="scroll_view_1_button_1">Button 1</string>
|
<string name="scroll_view_1_button_1">Button 1</string>
|
||||||
<string name="scroll_view_1_text_2">Text View 2</string>
|
<string name="scroll_view_1_text_2">Text View 2</string>
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 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.app;
|
||||||
|
|
||||||
|
import com.example.android.apis.R;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.view.WindowManager.LayoutParams;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
|
import android.widget.RadioGroup;
|
||||||
|
|
||||||
|
|
||||||
|
public class RotationAnimation extends Activity {
|
||||||
|
|
||||||
|
private int mRotationAnimation = LayoutParams.ROTATION_ANIMATION_ROTATE;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
setRotationAnimation(mRotationAnimation);
|
||||||
|
|
||||||
|
setContentView(R.layout.rotation_animation);
|
||||||
|
|
||||||
|
((CheckBox)findViewById(R.id.windowFullscreen)).setOnCheckedChangeListener(
|
||||||
|
new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
setFullscreen(isChecked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
((RadioGroup)findViewById(R.id.rotation_radio_group)).setOnCheckedChangeListener(
|
||||||
|
new RadioGroup.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||||
|
switch (checkedId) {
|
||||||
|
default:
|
||||||
|
case R.id.rotate:
|
||||||
|
mRotationAnimation = LayoutParams.ROTATION_ANIMATION_ROTATE;
|
||||||
|
break;
|
||||||
|
case R.id.crossfade:
|
||||||
|
mRotationAnimation = LayoutParams.ROTATION_ANIMATION_CROSSFADE;
|
||||||
|
break;
|
||||||
|
case R.id.jumpcut:
|
||||||
|
mRotationAnimation = LayoutParams.ROTATION_ANIMATION_JUMPCUT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
setRotationAnimation(mRotationAnimation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setFullscreen(boolean on) {
|
||||||
|
Window win = getWindow();
|
||||||
|
WindowManager.LayoutParams winParams = win.getAttributes();
|
||||||
|
if (on) {
|
||||||
|
winParams.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
||||||
|
} else {
|
||||||
|
winParams.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
||||||
|
}
|
||||||
|
win.setAttributes(winParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setRotationAnimation(int rotationAnimation) {
|
||||||
|
Window win = getWindow();
|
||||||
|
WindowManager.LayoutParams winParams = win.getAttributes();
|
||||||
|
winParams.rotationAnimation = rotationAnimation;
|
||||||
|
win.setAttributes(winParams);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user