在Android如何使用DoubleSeekBar双向选择控件

  介绍

本篇文章为大家展示了在Android如何使用DoubleSeekBar双向选择控件,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

先看效果图

在Android如何使用DoubleSeekBar双向选择控件

1。DoubleSlideSeekBar

公共类DoubleSlideSeekBar扩展视图{/* *
  *线条(进度条)的宽度
  */私人int线宽;/* *
  *线条(进度条)的长度
  */私人int lineLength=400;/* *
  *字所在的高度100美元
  */私人int textHeight;/* *
  *游标图片宽度
  */私人int imageWidth;/* *
  *游标图片高度
  */私人int imageHeight;/* *
  *是否有刻度线
  */私人布尔hasRule;/* *
  *左边的游标是否在动
  */私人布尔isLowerMoving;/* *
  *右边的游标是否在动
  */私人布尔isUpperMoving;/* *
  *字的大小100美元
  */私人int textSize;/* *
  100美元*字的颜色
  */私人int输入textColor;/* *
  *两个游标内部线(进度条)的颜色
  */私人int inColor=Color.BLUE;/* *
  *两个游标外部线(进度条)的颜色
  */私人int outColor=Color.BLUE;/* *
  *刻度的颜色
  */私人int ruleColor=Color.BLUE;/* *
  *刻度上边的字的颜色
  */私人int ruleTextColor=Color.BLUE;/* *
  *左边图标的图片
  */私人位图bitmapLow;/* *
  *右边图标的图片
  */私人位图bitmapBig;/* *
  *左边图标所在X轴的位置
  */私人int slideLowX;/* *
  *右边图标所在X轴的位置
  */私人int slideBigX;/* *
  *图标(游标)高度
  */私人int bitmapHeight;/* *
  *图标(游标)宽度
  */私人int bitmapWidth;/* *
  *加一些填充大小酌情考虑为了我们的自定义视图可以显示完整
  */私人int paddingLeft=100;
  私人int paddingRight=100;
  私人int paddingTop=50;
  私人int paddingBottom=10;/* *
  *线(进度条)开始的位置
  */私人int lineStart=paddingLeft;/* *
  *线的Y轴位置
  */私人int细的;/* *
  *线(进度条)的结束位置
  */私人int lineEnd=lineLength + paddingLeft;/* *
  *选择器的最大值
  */私人int bigValue=https://www.yisu.com/zixun/100;/* *
  *选择器的最小值
  */私人int smallValue=0;/* *
  *选择器的当前最小值
  */私人smallRange浮动;/* *
  *选择器的当前最大值
  */私人bigRange浮动;/* *
  *单位元
  */私人字符串单元=" ";/* *
  *单位份数
  */私人int==20;/* *
  *刻度单位美元
  */私人字符串ruleUnit=" ";/* *
  *刻度上边文字的大小
  */私人int ruleTextSize=20;/* *
  *刻度线的高度
  */私人int ruleLineHeight=20;
  私人油漆linePaint;
  私人油漆bitmapPaint;
  私人油漆textPaint;
  私人油漆paintRule;
  
  公共DoubleSlideSeekBar(上下文语境){
  这(上下文,null);
  }
  
  公共DoubleSlideSeekBar(上下文语境,@Nullable AttributeSet attrs) {
  这(上下文、attrs 0);
  }
  
  公共DoubleSlideSeekBar(上下文语境,@Nullable AttributeSet attrs, int defStyleAttr) {
  超级(上下文、attrs defStyleAttr);
  TypedArray TypedArray=context.getTheme ()。obtainStyledAttributes (attrs R.styleable。DoubleSlideSeekBar defStyleAttr 0);
  int大?typedArray.getIndexCount ();
  for (int i=0;我<大小;我+ +){
  int类型=typedArray.getIndex(我);
  开关(类型){
  案例R.styleable.DoubleSlideSeekBar_inColor:
  inColor=typedArray。色鬼(类型、Color.BLACK);
  打破;
  案例R.styleable.DoubleSlideSeekBar_lineHeight:
  线宽=typedArray (int)。getDimension(类型、dip2px (getContext (), 10));
  打破;
  案例R.styleable.DoubleSlideSeekBar_outColor:
  outColor=typedArray。色鬼(类型、Color.YELLOW);
  打破;
  案例R.styleable.DoubleSlideSeekBar_textColor:
  输入textColor=typedArray。色鬼(类型、Color.BLUE);
  打破;
  案例R.styleable.DoubleSlideSeekBar_textSize:
  textSize=typedArray。getDimensionPixelSize(类型,(int) TypedValue.applyDimension (
  TypedValue。.getDisplayMetrics COMPLEX_UNIT_SP 16 getresource () ()));
  打破;
  案例R.styleable.DoubleSlideSeekBar_imageLow:
  typedArray bitmapLow=BitmapFactory.decodeResource (getresource ()。getResourceId(类型,0));
  打破;
  案例R.styleable.DoubleSlideSeekBar_imageBig:
  typedArray bitmapBig=BitmapFactory.decodeResource (getresource ()。getResourceId(类型,0));
  打破;
  案例R.styleable.DoubleSlideSeekBar_imageheight:
  typedArray imageHeight=(int)。getDimension(类型、dip2px (getContext (), 20));
  打破;
  案例R.styleable.DoubleSlideSeekBar_imagewidth:
  typedArray imageWidth=(int)。getDimension(类型、dip2px (getContext (), 20));
  打破;
  案例R.styleable.DoubleSlideSeekBar_hasRule:
  hasRule=typedArray。getBoolean(类型、假);
  打破;
  案例R.styleable.DoubleSlideSeekBar_ruleColor:
  ruleColor=typedArray。色鬼(类型、Color.BLUE);
  打破;
  案例R.styleable.DoubleSlideSeekBar_ruleTextColor:
  ruleTextColor=typedArray。色鬼(类型、Color.BLUE);
  打破;
  案例R.styleable.DoubleSlideSeekBar_unit:
  单位=typedArray.getString(类型);
  打破;
  案例R.styleable.DoubleSlideSeekBar_equal:==typedArray。getInt(类型、10);
  打破;
  案例R.styleable.DoubleSlideSeekBar_ruleUnit:
  ruleUnit=typedArray.getString(类型);
  打破;
  案例R.styleable.DoubleSlideSeekBar_ruleTextSize:
  ruleTextSize=typedArray。getDimensionPixelSize(类型,(int) TypedValue.applyDimension (
  TypedValue。.getDisplayMetrics COMPLEX_UNIT_SP 16 getresource () ()));
  打破;
  案例R.styleable.DoubleSlideSeekBar_ruleLineHeight:
  typedArray ruleLineHeight=(int)。getDimension(类型、dip2px (getContext (), 10));
  打破;
  案例R.styleable.DoubleSlideSeekBar_bigValue:
  bigValue=typedArray。getInteger(类型,100);
  打破;
  案例R.styleable.DoubleSlideSeekBar_smallValue:
  smallValue=typedArray。getInteger(类型,100);
  打破;
  
  
  默认值:
  打破;
  }
  }
  typedArray.recycle ();
  init ();
  }
  
  私人空间init () {/* *游标的默认图*/如果(bitmapLow==null) {
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null

在Android如何使用DoubleSeekBar双向选择控件