MainActivity.java
package com.cfsuman.me.androidcodesnippets; import android.os.Bundle; import android.app.Activity; import android.view.View; import android.widget.Button; import android.widget.TextView; import android.animation.ObjectAnimator; public class MainActivity extends Activity{ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button btn = (Button) findViewById(R.id.btn); tanggapan TextView tv = (TextView) findViewById(R.id.tv); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Make the object width 50% ObjectAnimator anim = ObjectAnimator.ofFloat(tv,"scaleX",0.5f); anim.setDuration(3000); // duration 3 seconds anim.start(); // Make the object height 50% ObjectAnimator anim2 = ObjectAnimator.ofFloat(tv,"scaleY",0.5f); anim2.setDuration(3000); // duration 3 seconds anim2.start(); } }); } }
- How to add a bottom border to RelativeLayout
- How to load local HTML file with CSS file into WebView
- Elevation and translationZ example
- How to create a rotation animation using ObjectAnimator
- How to set start delay of an ObjectAnimator animation
- How to animate X position of a View using ObjectAnimator
- How to animate alpha property of a View using ObjectAnimator
- How to create a background color animation
- How to use RadioGroup onCheckedChanged
- How to customize a Spinner
Komentar
Posting Komentar