@OnClick({
R.id.topBg,//顶部的三个按钮
R.id.btn_tools, R.id.btn_album, R.id.btn_video})publicvoidonViewClicked(View view){switch(view.getId()){case R.id.topBg:break;case R.id.btn_video:changeBgImg(1);break;case R.id.btn_tools:changeBgImg(2);break;case R.id.btn_album:changeBgImg(3);break;}}privatevoidchangeBgImg(int id){
String imageName ="bg_make_story_"+id;// Toast.makeText(application, "getResource(imageName):"+getResource(imageName), Toast.LENGTH_SHORT).show();
Glide.with(this).load(getResource(imageName)).crossFade().animate(animationObject).skipMemoryCache(true).into(topBg);}
ViewPropertyAnimation.Animator animationObject =newViewPropertyAnimation.Animator(){@Overridepublicvoidanimate(View view){// if it's a custom view class, cast it here// then find subviews and do the animations// here, we just use the entire view for the fade animation
view.setAlpha(0f);
ObjectAnimator fadeAnim = ObjectAnimator.ofFloat( view,"alpha",0f,1f);
fadeAnim.setDuration(2500);
fadeAnim.start();}};publicintgetResource(String imageName){
Context ctx=getBaseContext();int resId =getResources().getIdentifier(imageName,"mipmap", ctx.getPackageName());//如果没有在"mipmap"下找到imageName,将会返回0return resId;}