カスタムマルチピクチャオーバーラップview
14540 ワード
マルチビューオーバーラップ
FrameLayoutを使用して、複数のviewを重ねて参照を表示します.https://blog.csdn.net/hemeinvyiqiluoben/article/details/50499092
https://blog.csdn.net/u012995888/article/details/80189486
UI開発リファレンス
https://blog.csdn.net/Hystudio_lzu/article/details/78570581
カスタムview
https://www.jianshu.com/p/705a6cb6bfee
例
FrameLayoutを使用して、複数のviewを重ねて参照を表示します.https://blog.csdn.net/hemeinvyiqiluoben/article/details/50499092
https://blog.csdn.net/u012995888/article/details/80189486
UI開発リファレンス
https://blog.csdn.net/Hystudio_lzu/article/details/78570581
カスタムview
https://www.jianshu.com/p/705a6cb6bfee
例
package com.example.myapplication1;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.LinearInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.Nullable;
public class MyView extends FrameLayout {
Float mDegree;
ImageView circle1;
ImageView line1;
TextView logText;
ObjectAnimator circleAnim;
public MyView(Context context) {
super(context);
}
public MyView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
circle1 = new ImageView(getContext());
circle1.setImageResource(R.drawable.ic_data_usage_black_24dp);
line1 = new ImageView(getContext());
line1.setImageResource(R.drawable.ic_linear_scale_black_24dp);
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
this.addView(circle1, params);
this.addView(line1, params);
this.setBackgroundColor(Color.RED);
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(circle1, "rotation", 0f, 360f).setDuration(6000);
objectAnimator.setRepeatCount(ValueAnimator.INFINITE);
objectAnimator.setInterpolator(new LinearInterpolator());
objectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mDegree = (Float) animation.getAnimatedValue("rotation");
}
});
objectAnimator.start();
circleAnim = objectAnimator;
this.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
changeImage(v);
}
});
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
}
// @Override
// protected void onLayout(boolean changed, int l, int t, int r, int b) {
// super.onLayout(changed, l, t, r, b);
// }
public void getCureentDegree(View view) {
logText.setText(mDegree + "");
}
public void changeImage(View view) {
Float cureentDegree = mDegree;
if (circleAnim != null) {
circleAnim.end();
circleAnim = null;
}
// circle1.setImageDrawable(getDrawable(R.drawable.ic_gps_off_black_24dp));
circle1.setRotation(cureentDegree);
}
}