Enhanced demo for view transformation properties
Change-Id: I01939513d7848b09ce17e7f604512a89062f446f
diff --git a/samples/ApiDemos/res/layout/rotating_view.xml b/samples/ApiDemos/res/layout/rotating_view.xml
index 5f18856..09185a6 100644
--- a/samples/ApiDemos/res/layout/rotating_view.xml
+++ b/samples/ApiDemos/res/layout/rotating_view.xml
@@ -31,13 +31,29 @@
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:textStyle="bold"
- android:text="X"
+ android:text="TX"
/>
<SeekBar
android:orientation="horizontal"
+ android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:id="@+id/rotationX"
+ android:id="@+id/translationX"
+ />
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingLeft="15dip"
+ android:paddingRight="5dip"
+ android:textStyle="bold"
+ android:text="TY"
+ />
+ <SeekBar
+ android:orientation="horizontal"
+ android:layout_weight="1"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:id="@+id/translationY"
/>
</LinearLayout>
<LinearLayout
@@ -52,31 +68,78 @@
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:textStyle="bold"
+ android:text="SX"
+ />
+ <SeekBar
+ android:orientation="horizontal"
+ android:layout_weight="1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/scaleX"
+ />
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingLeft="15dip"
+ android:paddingRight="5dip"
+ android:textStyle="bold"
+ android:text="SY"
+ />
+ <SeekBar
+ android:orientation="horizontal"
+ android:layout_weight="1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/scaleY"
+ />
+ </LinearLayout>
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="20dip"
+ >
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingLeft="5dip"
+ android:paddingRight="5dip"
+ android:textStyle="bold"
+ android:text="X"
+ />
+ <SeekBar
+ android:orientation="horizontal"
+ android:layout_weight="1"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:id="@+id/rotationX"
+ />
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingLeft="15dip"
+ android:paddingRight="5dip"
+ android:textStyle="bold"
android:text="Y"
/>
<SeekBar
android:orientation="horizontal"
+ android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/rotationY"
/>
- </LinearLayout>
- <LinearLayout
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="20dip"
- >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:paddingLeft="5dip"
+ android:paddingLeft="15dip"
android:paddingRight="5dip"
android:textStyle="bold"
android:text="Z"
/>
<SeekBar
android:orientation="horizontal"
+ android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/rotationZ"
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/RotatingButton.java b/samples/ApiDemos/src/com/example/android/apis/view/RotatingButton.java
index 1b65c5c..67d6e3c 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/RotatingButton.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/RotatingButton.java
@@ -26,9 +26,9 @@
import android.widget.SeekBar;
/**
- * This application demonstrates the seeking capability of ValueAnimator. The SeekBar in the
- * UI allows you to set the position of the animation. Pressing the Run button will play from
- * the current position of the animation.
+ * This application demonstrates the ability to transform views in 2D and 3D, scaling them,
+ * translating them, and rotating them (in 2D and 3D). Use the seek bars to set the various
+ * transform properties of the button.
*/
public class RotatingButton extends Activity {
@@ -39,6 +39,80 @@
setContentView(R.layout.rotating_view);
final Button rotatingButton = (Button) findViewById(R.id.rotatingButton);
SeekBar seekBar;
+ seekBar = (SeekBar) findViewById(R.id.translationX);
+ seekBar.setMax(400);
+ seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress,
+ boolean fromUser) {
+ rotatingButton.setTranslationX((float)progress);
+ }
+ });
+ seekBar = (SeekBar) findViewById(R.id.translationY);
+ seekBar.setMax(800);
+ seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress,
+ boolean fromUser) {
+ rotatingButton.setTranslationY((float)progress);
+ }
+ });
+ seekBar = (SeekBar) findViewById(R.id.scaleX);
+ seekBar.setMax(50);
+ seekBar.setProgress(10);
+ seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress,
+ boolean fromUser) {
+ rotatingButton.setScaleX((float)progress/10f);
+ }
+ });
+ seekBar = (SeekBar) findViewById(R.id.scaleY);
+ seekBar.setMax(50);
+ seekBar.setProgress(10);
+ seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress,
+ boolean fromUser) {
+ rotatingButton.setScaleY((float)progress/10f);
+ }
+ });
seekBar = (SeekBar) findViewById(R.id.rotationX);
seekBar.setMax(360);
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {