2.睡了一觉第二天我觉得不合适太消耗内存了,性能了怎么办呢,我就用移动布局的办法实现了一个。
3.到了周六日没事了,我说在改改吧,后来我用动画实现了一拨。当然下面肯定也是几个texview没有自定义,因为消耗性能。
我在网上找了半天都是直接自定义画的,要么性能卡的,要么大家可以自己看看都不太行,
package com.aquarius.customview;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.Pair;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import java.util.ArrayList;
import java.util.Random;
/**
* Created by aquarius on 17-4-11.
*/
public class LotteryView extends View {
private int mScreenWidth; // 屏幕宽度
private int mScreenHeight; // 屏幕高度
private int mSelfTotalWidth; // 自身最大的宽度
private static float DEFAULT_SIZE_FACTOR = 0.85f; // 自身占用屏幕宽度的比例
private int mOuterCircleWidth; // 最外边圆环
private Paint mOuterCirclePaint;
private int mOuterCircleBackgroundColor;
private Paint mInnerPaint;
private int mInnerCircleBackgroundColor;
private Paint mSmallCirclePaint;
private int mSmallCircleBlueColor;
private int mSmallCircleYellowColor;
private int mInnerCardTextColor;
private int mInnerCardWidth; // 卡片宽度
private int mInnerCardSpace; // 卡片间隔
private boolean mHadInitial = false;
private ArrayList<Pair<Pair<Integer, Integer>,Pair<Integer, Integer>>> mCardPositionInfoList;
private Context mContext;
private AlertDialog mAlertDialog;
private int[] mPicResId;
private String[] mInfoResArray;
private Rect mBounds = new Rect();
private float mSmallInfoTextSize;
private float mBigInfoTextSize;
private boolean mNeedRandomTimes = false;
private int mInvalidateInnerCardCount;
private int mLotteryInvalidateTimes;
private boolean mStartAnimation = false; // not real animation
private boolean mLastEndSelected = false;
private boolean mStartflag;
private String mFlag;
public LotteryView(Context context) {
this(context, null);
}
public LotteryView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public LotteryView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context, attrs);
}
private void init(Context context, AttributeSet attrs) {
mContext = context;
acquireCustomAttValues(context, attrs);
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics dm = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(dm);
mScreenWidth = dm.widthPixels;
mScreenHeight = dm.heightPixels;
mSelfTotalWidth = mScreenWidth < mScreenHeight ?
(int)(mScreenWidth ) : (int)(mScreenHeight);
mSmallInfoTextSize = context.getResources().getDimension(R.dimen.lotteryview_inner_card_text_size);
mBigInfoTextSize = context.getResources().getDimension(R.dimen.lotteryview_inner_card_big_text_size);
mOuterCircleWidth = (int) context.getResources().getDimension(R.dimen.lotteryview_outer_circle_width);
mInnerCardSpace =4;//(int) context.getResources().getDimension(R.dimen.lotteryview_inner_card_blank);//卡片之间距离
mInnerCardWidth = (mSelfTotalWidth- getPaddingLeft() -getPaddingRight() - mOuterCircleWidth * 2 - mInnerCardSpace * 4) / 3;
mInnerCardTextColor = context.getResources().getColor(R.color.inner_card_text_color);
mOuterCircleBackgroundColor