下面列出了android.graphics.drawable.AnimationDrawable#setEnterFadeDuration() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* start the gradient anim
*/
public void startGradientAnimation(){
if(mView!=null){
mView.setBackgroundResource(mGradientAnimation);
mAnimationDrawable = (AnimationDrawable) mView.getBackground();
if(mAnimationDrawable!=null){
mView.setBackground(mAnimationDrawable);
mAnimationDrawable.setEnterFadeDuration(mDuration);
mAnimationDrawable.setExitFadeDuration(mDuration);
mView.post(new Runnable() {
@Override
public void run() {
mAnimationDrawable.start();
}
});
}
}
}
private void initAnim() {
animationDrawable = new AnimationDrawable();
animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode1), 100);
animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode2), 100);
animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode3), 100);
animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode4), 100);
animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode5), 100);
animationDrawable.setOneShot(true);
animationDrawable.setExitFadeDuration(300);
animationDrawable.setEnterFadeDuration(100);
ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(null, "scaleX", 1.f, 0.f);
ObjectAnimator objectAnimator2 = ObjectAnimator.ofFloat(null, "scaleY", 1.f, 0.f);
animatorSet = new AnimatorSet();
animatorSet.setDuration(300l);
animatorSet.playTogether(objectAnimator1, objectAnimator2);
objectAnimator = ObjectAnimator.ofFloat(null, "alpha", 1.f, 0.f);
objectAnimator.setDuration(2000l);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.signup_layout, container, false);
mContext = this.getActivity();
full_name = view.findViewById(R.id.full_name);
email = view.findViewById(R.id.email);
password = view.findViewById(R.id.password);
phone = view.findViewById(R.id.phone);
animation_view_fullname = view.findViewById(R.id.animation_view_fullname);
animation_view_email = view.findViewById(R.id.animation_view_email);
animation_view_password = view.findViewById(R.id.animation_view_password);
animation_view_phone = view.findViewById(R.id.animation_view_phone);
animation_view_location = view.findViewById(R.id.animation_view_location);
animation_view_birth_signup = view.findViewById(R.id.animation_view_birth_signup);
buttonRegister = view.findViewById(R.id.buttonRegister);
determine_location = view.findViewById(R.id.determine_location);
Date_of_Birth = view.findViewById(R.id.Date_of_Birth);
background_layout_signup = view.findViewById(R.id.background_layout_signup);
anim = (AnimationDrawable) background_layout_signup.getBackground();
anim.setEnterFadeDuration(4000);
anim.setExitFadeDuration(4000);
buttonRegister.setOnClickListener(this);
determine_location.setOnClickListener(this);
Date_of_Birth.setOnClickListener(this);
getDetailsMANUFACTURER();
validateFields2();
return view;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_follow_user_input);
LinearLayout container = (LinearLayout) findViewById(R.id.container);
anim = (AnimationDrawable) container.getBackground();
anim.setEnterFadeDuration(6000);
anim.setExitFadeDuration(2000);
}
public ItemConversationAdapter(Context context, List<ConversationEntity> objects) {
this.context = context;
this.layoutInflater = LayoutInflater.from(context);
this.objects = objects;
animationDrawable = new AnimationDrawable();
animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode1), 100);
animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode2), 100);
animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode3), 100);
animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode4), 100);
animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode5), 100);
animationDrawable.setOneShot(true);
animationDrawable.setExitFadeDuration(300);
animationDrawable.setEnterFadeDuration(100);
}
private void init() {
setBackgroundResource(draw);
final AnimationDrawable frameAnimation = (AnimationDrawable) getBackground();
frameAnimation.setEnterFadeDuration(duration);
frameAnimation.setExitFadeDuration(duration);
post(new Runnable(){
public void run(){
frameAnimation.start();
}
});
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.login_fragment, container, false);
terms = view.findViewById(R.id.terms);
error_message = view.findViewById(R.id.error_message);
login_btn = view.findViewById(R.id.login_btn);
back_login_fragment = view.findViewById(R.id.back_login_fragment);
login_email = view.findViewById(R.id.login_email);
login_password = view.findViewById(R.id.login_password);
background_layout = view.findViewById(R.id.background_layout);
mContext = this.getActivity();
login_password.setOnEditorActionListener(new EditText.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
login();
return true;
}
return false;
}
});
login_btn.setOnClickListener(this);
back_login_fragment.setOnClickListener(this);
anim = (AnimationDrawable) background_layout.getBackground();
anim.setEnterFadeDuration(4000);
anim.setExitFadeDuration(4000);
check_edittext_fileds();
return view;
}