Merge "Enhanced demo for view transformation properties"

This commit is contained in:
Chet Haase
2010-09-09 15:35:56 -07:00
committed by Android (Google) Code Review
2 changed files with 150 additions and 13 deletions

View File

@@ -31,13 +31,29 @@
android:paddingLeft="5dip" android:paddingLeft="5dip"
android:paddingRight="5dip" android:paddingRight="5dip"
android:textStyle="bold" android:textStyle="bold"
android:text="X" android:text="TX"
/> />
<SeekBar <SeekBar
android:orientation="horizontal" android:orientation="horizontal"
android:layout_weight="1"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" 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>
<LinearLayout <LinearLayout
@@ -52,31 +68,78 @@
android:paddingLeft="5dip" android:paddingLeft="5dip"
android:paddingRight="5dip" android:paddingRight="5dip"
android:textStyle="bold" 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" android:text="Y"
/> />
<SeekBar <SeekBar
android:orientation="horizontal" android:orientation="horizontal"
android:layout_weight="1"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/rotationY" android:id="@+id/rotationY"
/> />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dip"
>
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="5dip" android:paddingLeft="15dip"
android:paddingRight="5dip" android:paddingRight="5dip"
android:textStyle="bold" android:textStyle="bold"
android:text="Z" android:text="Z"
/> />
<SeekBar <SeekBar
android:orientation="horizontal" android:orientation="horizontal"
android:layout_weight="1"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/rotationZ" android:id="@+id/rotationZ"

View File

@@ -26,9 +26,9 @@ import android.widget.Button;
import android.widget.SeekBar; import android.widget.SeekBar;
/** /**
* This application demonstrates the seeking capability of ValueAnimator. The SeekBar in the * This application demonstrates the ability to transform views in 2D and 3D, scaling them,
* UI allows you to set the position of the animation. Pressing the Run button will play from * translating them, and rotating them (in 2D and 3D). Use the seek bars to set the various
* the current position of the animation. * transform properties of the button.
*/ */
public class RotatingButton extends Activity { public class RotatingButton extends Activity {
@@ -39,6 +39,80 @@ public class RotatingButton extends Activity {
setContentView(R.layout.rotating_view); setContentView(R.layout.rotating_view);
final Button rotatingButton = (Button) findViewById(R.id.rotatingButton); final Button rotatingButton = (Button) findViewById(R.id.rotatingButton);
SeekBar seekBar; 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 = (SeekBar) findViewById(R.id.rotationX);
seekBar.setMax(360); seekBar.setMax(360);
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {