From aaed6c9f94f233e37fc0c2d03bd5543d196053ec Mon Sep 17 00:00:00 2001 From: liyujiang Date: Wed, 21 Dec 2016 23:28:45 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=99=A8=E6=9D=A1=E7=9B=AE?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=98=BE=E7=A4=BA=E7=94=B13=E6=9D=A1?= =?UTF-8?q?=E6=94=B9=E4=B8=BA5=E6=9D=A1=EF=BC=8C=E5=B9=B6=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=9D=A1=E7=9B=AE=E6=96=87=E5=AD=97=E7=9A=84=E5=86=85?= =?UTF-8?q?=E8=BE=B9=E8=B7=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 4 ++-- .../qqtheme/framework/picker/WheelPicker.java | 13 +++++++++++-- .../cn/qqtheme/framework/widget/WheelView.java | 18 +++++++++++------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/gradle.properties b/gradle.properties index 110ce37f..b5ba75d1 100755 --- a/gradle.properties +++ b/gradle.properties @@ -15,8 +15,8 @@ com.android.build.gradle.overridePathCheck=true #android.useDeprecatedNdk=true #下面定义一些常量供gradle脚本使用 -VERSION_NAME=1.3.2 -VERSION_CODE=132 +VERSION_NAME=1.3.3 +VERSION_CODE=133 COMPILE_SDK_VERSION=23 MIN_SDK_VERSION=11 #安卓6.0开始(API23+),需要动态申请权限 diff --git a/library/WheelPicker/src/main/java/cn/qqtheme/framework/picker/WheelPicker.java b/library/WheelPicker/src/main/java/cn/qqtheme/framework/picker/WheelPicker.java index 141b4978..b88ba67e 100755 --- a/library/WheelPicker/src/main/java/cn/qqtheme/framework/picker/WheelPicker.java +++ b/library/WheelPicker/src/main/java/cn/qqtheme/framework/picker/WheelPicker.java @@ -82,8 +82,17 @@ public void setLineConfig(@Nullable WheelView.LineConfig config) { } /** - * 设置选项偏移量,默认为1,范围为1-4。 - * 1显示三条、2显示5条、3显示7条、4显示9条 + * 使用最长的分割线,多级选择器时可以实现连线效果 + * + * @see #setLineConfig(WheelView.LineConfig) + */ + public void useMaxRatioLine() { + lineConfig = new WheelView.LineConfig(0); + } + + /** + * 设置选项偏移量,可用来要设置显示的条目数,范围为1-3。 + * 1显示3条、2显示5条、3显示7条 */ public void setOffset(@IntRange(from = 1, to = 3) int offset) { this.offset = offset; diff --git a/library/WheelPicker/src/main/java/cn/qqtheme/framework/widget/WheelView.java b/library/WheelPicker/src/main/java/cn/qqtheme/framework/widget/WheelView.java index 3e69f1b5..aea6e76b 100755 --- a/library/WheelPicker/src/main/java/cn/qqtheme/framework/widget/WheelView.java +++ b/library/WheelPicker/src/main/java/cn/qqtheme/framework/widget/WheelView.java @@ -43,14 +43,17 @@ */ public class WheelView extends ScrollView { public static final int TEXT_SIZE = 20; - public static final int TEXT_PADDING = 10; + public static final int TEXT_PADDING_TOP_BOTTOM = 8; + public static final int TEXT_PADDING_LEFT_RIGHT = 15; public static final int TEXT_COLOR_FOCUS = 0XFF0288CE; public static final int TEXT_COLOR_NORMAL = 0XFFBBBBBB; public static final int LINE_ALPHA = 150; public static final int LINE_COLOR = 0XFF83CDE6; public static final float LINE_THICK = 1f; - public static final int OFF_SET = 1; - private static final int DELAY = 30; + public static final int OFF_SET = 2; + private static final int DELAY = 50; + private static final int MATCH_PARENT = ViewGroup.LayoutParams.MATCH_PARENT; + private static final int WRAP_CONTENT = ViewGroup.LayoutParams.WRAP_CONTENT; private Context context; private LinearLayout views;//容器 @@ -129,21 +132,22 @@ private void initData() { private TextView createView(String item) { TextView tv = new TextView(context); - tv.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); + tv.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT)); tv.setSingleLine(true); tv.setEllipsize(TextUtils.TruncateAt.END); tv.setText(item); tv.setTextSize(textSize); tv.setGravity(Gravity.CENTER); - int padding = ConvertUtils.toPx(context, TEXT_PADDING); - tv.setPadding(padding, padding, padding, padding); + int paddingTopBottom = ConvertUtils.toPx(context, TEXT_PADDING_TOP_BOTTOM); + int paddingLeftRight = ConvertUtils.toPx(context, TEXT_PADDING_LEFT_RIGHT); + tv.setPadding(paddingLeftRight, paddingTopBottom, paddingLeftRight, paddingTopBottom); if (0 == itemHeight) { int wSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); int hSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); tv.measure(wSpec, hSpec); itemHeight = tv.getMeasuredHeight(); LogUtils.verbose(this, "itemHeight: " + itemHeight); - views.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, itemHeight * displayItemCount)); + views.setLayoutParams(new LayoutParams(MATCH_PARENT, itemHeight * displayItemCount)); LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) getLayoutParams(); setLayoutParams(new LinearLayout.LayoutParams(lp.width, itemHeight * displayItemCount)); }