Android 仿微信小程序开屏页加载loading
废话不多说,先上效果图~
首先就是底层有一个灰色的圆,然后按照圆形的轨迹进行绘制。
啊~说那么多也没用,还是直接上代码吧,哈哈哈哈
绘制底部圆形及轨迹:
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PaintFlagsDrawFilter;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public class miniAppStartLoadingView extends View {
private int mTotalWidth, mTotalHeight;
private int mCenterX, mCenterY;
//底色画笔
private Paint mCirclePaint;
//进度条画笔
private Paint mProgressPaint;
private float sweepAngle = 10;
private int startAngle = 1;
public miniAppStartLoadingView(@NonNull Context context) {
super(context);
initPaint(context);
}