最近公司项目紧张,许久没来看博客了,现在因项目需要,特将用到的控件做了个大概出来,具体效果图如下,详细细节需自己考量修改:
其实这个不是最好的。最好是全部drawing。。 我已经实现了,下次有时间再更换源码和效果图
部分代码如下:
private Context context; private static final int DEFAULT_PAINT_STROKE_WIDTH = 8; private static final int DEFAULT_FILLED_COLOR = Color.parseColor("#FFA500"); private static final int DEFAULT_EMPTY_COLOR = Color.parseColor("#ff0000"); /** * rangebar粗细 */ private static final float DEFAULT_BAR_HEIGHT_PERCENT = 0.10f; //设置长度 private static final int DEFAULT_RANGE_COUNT = 8; /** * rangebar高度 */ private static final int DEFAULT_HEIGHT_IN_DP = 90; /** * bar的填充画笔 */ protected Paint paint; protected Paint mPaint; private int currentIndex; private float currentSlidingX; private float currentSlidingY; //具体数值 private int[] circlePositions; //用于绘制bar长度 private float[] circlePositions2 = new float[DEFAULT_RANGE_COUNT]; private int filledColor = DEFAULT_FILLED_COLOR; private int emptyColor = DEFAULT_EMPTY_COLOR; private float barHeightPercent = DEFAULT_BAR_HEIGHT_PERCENT; private int rangeCount = DEFAULT_RANGE_COUNT; private int barHeight, locationY; private float downX; private float downY; // private Bitmap bitmap_point; private int layoutHeight; // private boolean mPopupStyle;//是否显示pop private PopupWindow mPopup; View popView; TextView tv; int indexNum; //位置数值 private int[] mPosition; public RangeSliderBar(Context context) { this(context, null); this.context = context; initPop(); } public RangeSliderBar(Context context, AttributeSet attrs) { this(context, attrs, -1); this.context = context; initPop(); } public void setContext(Context context){ this.context = context; } public void setShowPopText(String str){ tv.setText(str); } void initPop(){ mPosition = new int[2]; popView = LayoutInflater.from(context).inflate(R.layout.seekbar_pop, null); mPopup=new PopupWindow(popView,popView.getWidth(),popView.getHeight(),true); tv = (TextView) popView.findViewById(R.id.tv_showtxt); }源码链接