//属性动画
ObjectAnimator moveIn = ObjectAnimator.ofFloat(tp, "translationX", 0f, 500f);
ObjectAnimator rotate = ObjectAnimator.ofFloat(tp, "rotation", 0f, 360f);
ObjectAnimator fadeInOut = ObjectAnimator.ofFloat(tp, "alpha", 1f, 0.5f, 1f);
AnimatorSet animSet = new AnimatorSet();
//通过各种方法把单个动画组成一块
animSet.play(rotate).with(fadeInOut).after(moveIn);
animSet.setDuration(3000);
animSet.start();
new Handler().postDelayed(new Runnable(){
public void run() {
Intent intent = new Intent(MainActivity.this, Liushi.class);
startActivity(intent);
}
}, 3000);
//流式布局view
int zuo=20;
int shang=20;
public LiushiView(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.LiushiView);
String string = typedArray.getString(R.styleable.LiushiView_text);
int color = typedArray.getColor(R.styleable.LiushiView_color, Color.BLACK);
typedArray.recycle();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
measureChildren(widthMeasureSpec, heightMeasureSpec);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
int zuoyou=zuo;
int shangxia = shang;
for (int i=0;i<getChildCount();i++){
int measuredHeight = getChildAt(i).getMeasuredHeight();
int measuredWidth = getChildAt(i).getMeasuredWidth();
if (measuredWidth+zuo+zuoyou>getWidth()){
zuoyou=20;
shangxia+=measuredHeight+shang;
getChildAt(i).layout(zuoyou,shangxia,zuoyou+measuredWidth,shangxia+measuredHeight);
}
else{
getChildAt(i).layout(zuoyou,shangxia,zuoyou+measuredWidth,shangxia+measuredHeight);
}
zuoyou+=measuredWidth+zuo;
}
}