在前几天写的博客中,通过使用自定义View画了一个可以实现点值选择的seekBar,但是在实际使用中还是会有一点问题,在点击处于连个值之间时,如何进行选择等。本篇博客对上次的自定义View进行了重新编码,最新的效果如下:
只是对上次自定义的View进行了一些细节方面的优化,在这里就不详细叙述了,看一下具体实现代码:
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
/**
* Created by Administrator on 2017/8/27 0027.
*/
public class LevelSeekBar extends View {
private int mTextSize = 12;
private String[] labels = new String[]{
"L1","L2","L3","L4","L5"};
private float mPrewidth;
private int mWidth;
private int mHeight;
private int mDotSize;
private Paint mPaint;
private int mThumbnailSize;
private int count = 4;
private Bitmap mBasicLine;
private int mLine_position_y;
priv