十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
郑州app开发android属性动画。布局代码比较简单这里只显示结果图。
成都创新互联-专业网站定制、快速模板网站建设、高性价比浮山网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式浮山网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖浮山地区。费用合理售后完善,十载实体公司更值得信赖。
java代码如下
MainActivity.java
package cn.xhhkj.videoview;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.FragmentTransaction;
import android.graphics.drawable.AnimationDrawable;
import android.media.Mediaplayer;
import android.os.bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.bounceInterpolator;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Imagebutton;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "结果是";
private ImageView iv_image;
@Override
protected void onCreate(bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
iv_image = findViewbyId(R.id.iv_image);
}
public void set(View view) {
AnimatorSet as = new AnimatorSet();
ObjectAnimator oa = ObjectAnimator.ofFloat(iv_image, "translationX", 10, 50, 20, 100);
ObjectAnimator oa2 = ObjectAnimator.ofFloat(iv_image, "scaleY", 0.1f, 2, 1, 2);
ObjectAnimator oa3 = ObjectAnimator.ofFloat(iv_image, "alpha", 0, 0.5f, 0, 1);
ObjectAnimator oa4 = ObjectAnimator.ofFloat(iv_image, "rotationY", 0, 180, 90, 360);
as.setDuration(2000);
as.setTarget(iv_image);
as.playTogether(oa, oa2, oa3, oa4);
as.start();
}
public void translate(View view) {
ObjectAnimator oa = ObjectAnimator.ofFloat(iv_image, "translationX", 10, 50,20,100,150);
oa.setDuration(2000);
oa.start(); //开始动画
}
public void scale(View view) {
ObjectAnimator oa = ObjectAnimator.ofFloat(iv_image, "scaleY", 0.1f, 2, 1, 2);
oa.setDuration(2000);
oa.start();
}
public void rotate(View view) {
ObjectAnimator oa = ObjectAnimator.ofFloat(iv_image, "rotation", 0, 180, 90, 360);
oa.setDuration(2000);
oa.start();
}
public void alpha(View view) {
ObjectAnimator oa = ObjectAnimator.ofFloat(iv_image, "alpha", 0, 0.5f, 0, 1,0,1);
oa.setDuration(2000);
oa.start();
}
}