Skip to content

Commit 3be9bf2

Browse files
committed
可设置设置分隔线颜色及是否显示
1 parent 9137e2b commit 3be9bf2

10 files changed

Lines changed: 56 additions & 13 deletions

File tree

Core/src/main/java/cn/qqtheme/framework/popup/ConfirmPopup.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
public abstract class ConfirmPopup<V extends View> extends BottomPopup<View> implements View.OnClickListener {
2424
protected static final String TAG_SUBMIT = "submit";
2525
protected static final String TAG_CANCEL = "cancel";
26-
private boolean lineVisible = true;
27-
private int lineColor = 0xFFDDDDDD;
26+
private boolean topLineVisible = true;
27+
private int topLineColor = 0xFFDDDDDD;
2828
private boolean cancelVisible = true;
2929
private CharSequence cancelText = "", submitText = "";
3030
private int cancelTextColor = Color.BLACK;
@@ -39,12 +39,12 @@ public ConfirmPopup(Activity activity) {
3939

4040
protected abstract V initContentView();
4141

42-
public void setLineColor(int lineColor) {
43-
this.lineColor = lineColor;
42+
public void setTopLineColor(int topLineColor) {
43+
this.topLineColor = topLineColor;
4444
}
4545

46-
public void setLineVisible(boolean lineVisible) {
47-
this.lineVisible = lineVisible;
46+
public void setTopLineVisible(boolean topLineVisible) {
47+
this.topLineVisible = topLineVisible;
4848
}
4949

5050
public void setCancelVisible(boolean cancelVisible) {
@@ -110,10 +110,10 @@ protected View getView() {
110110
submitButton.setOnClickListener(this);
111111
topButtonLayout.addView(submitButton);
112112
rootLayout.addView(topButtonLayout);
113-
if (lineVisible) {
113+
if (topLineVisible) {
114114
View lineView = new View(activity);
115115
lineView.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, 1));
116-
lineView.setBackgroundColor(lineColor);
116+
lineView.setBackgroundColor(topLineColor);
117117
rootLayout.addView(lineView);
118118
}
119119
rootLayout.addView(initContentView());

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencies {
1414
}
1515
```
1616
注:
17-
旧版的基于android-wheel,在分支“branch_OldAndroidPicker”,和新版的差别比较大
17+
旧版的基于android-wheel,在分支“branch_OldAndroidPicker”。
1818
不断学习,持续完善,敬请关注。。。
1919
gradle为1.3.0,buildTools为23.0.1,sdk为23。
2020
滑轮选择器的名称较长时,将以“...”显示超出的部分。
@@ -37,6 +37,7 @@ gradle为1.3.0,buildTools为23.0.1,sdk为23。
3737
时间选择器:
3838
```java
3939
TimePicker picker = new TimePicker(this);
40+
picker.setTopLineVisible(false);
4041
picker.setOnTimePickListener(new TimePicker.OnTimePickListener() {
4142
@Override
4243
public void onTimePicked(String hour, String minute) {
@@ -94,7 +95,8 @@ gradle为1.3.0,buildTools为23.0.1,sdk为23。
9495
星座选择器:
9596
```java
9697
ConstellationPicker picker = new ConstellationPicker(this);
97-
picker.setTextColor(0xFFFF0000,0xFF999999);
98+
picker.setTopLineColor(0xFFEE0000);
99+
picker.setTextColor(0xFFFF0000, 0xFF999999);
98100
picker.setLineColor(0xFFEE0000);
99101
picker.setOnOptionPickListener(new OptionPicker.OnOptionPickListener() {
100102
@Override
@@ -105,6 +107,19 @@ gradle为1.3.0,buildTools为23.0.1,sdk为23。
105107
picker.show();
106108
```
107109

110+
生肖选择器:
111+
```java
112+
ChineseZodiacPicker picker = new ChineseZodiacPicker(this);
113+
picker.setLineVisible(false);
114+
picker.setOnOptionPickListener(new OptionPicker.OnOptionPickListener() {
115+
@Override
116+
public void onOptionPicked(String option) {
117+
showToast(option);
118+
}
119+
});
120+
picker.show();
121+
```
122+
108123
颜色选择器:
109124
```java
110125
ColorPicker picker = new ColorPicker(this);
@@ -161,10 +176,11 @@ https://github.com/alibaba/fastjson<br />
161176
![单项选择器效果图](/screenshots/option.gif)
162177
![地址选择器效果图](/screenshots/address.gif)
163178
![数字选择器效果图](/screenshots/number.gif)
179+
![星座选择器效果图](/screenshots/constellation.gif)
180+
![生肖选择器效果图](/screenshots/chinesezodiac.gif)
164181
![颜色选择器效果图](/screenshots/color.gif)
165182
![文件选择器效果图](/screenshots/file.gif)
166183
![目录选择器效果图](/screenshots/dir.gif)
167-
![星座选择器效果图](/screenshots/constellation.gif)
168184

169185
# Contact
170186
李玉江, QQ:1032694760, Email:liyujiang_tk@yeah.net

WheelPicker/src/main/java/cn/qqtheme/framework/picker/AddressPicker.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,23 @@ protected View initContentView() {
4949
provinceView.setLayoutParams(new LinearLayout.LayoutParams(screenWidth / 3, WRAP_CONTENT));
5050
provinceView.setTextSize(textSize);
5151
provinceView.setTextColor(textColorNormal, textColorFocus);
52+
provinceView.setLineVisible(lineVisible);
5253
provinceView.setLineColor(lineColor);
5354
provinceView.setOffset(offset);
5455
layout.addView(provinceView);
5556
final WheelView cityView = new WheelView(activity);
5657
cityView.setLayoutParams(new LinearLayout.LayoutParams(screenWidth / 3, WRAP_CONTENT));
5758
cityView.setTextSize(textSize);
5859
cityView.setTextColor(textColorNormal, textColorFocus);
60+
cityView.setLineVisible(lineVisible);
5961
cityView.setLineColor(lineColor);
6062
cityView.setOffset(offset);
6163
layout.addView(cityView);
6264
final WheelView countyView = new WheelView(activity);
6365
countyView.setLayoutParams(new LinearLayout.LayoutParams(screenWidth / 3, WRAP_CONTENT));
6466
countyView.setTextSize(textSize);
6567
countyView.setTextColor(textColorNormal, textColorFocus);
68+
countyView.setLineVisible(lineVisible);
6669
countyView.setLineColor(lineColor);
6770
countyView.setOffset(offset);
6871
layout.addView(countyView);

WheelPicker/src/main/java/cn/qqtheme/framework/picker/DatePicker.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ protected View initContentView() {
7272
yearView.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
7373
yearView.setTextSize(textSize);
7474
yearView.setTextColor(textColorNormal, textColorFocus);
75+
yearView.setLineVisible(lineVisible);
7576
yearView.setLineColor(lineColor);
7677
yearView.setOffset(offset);
7778
layout.addView(yearView);
@@ -87,6 +88,7 @@ protected View initContentView() {
8788
monthView.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
8889
monthView.setTextSize(textSize);
8990
monthView.setTextColor(textColorNormal, textColorFocus);
91+
monthView.setLineVisible(lineVisible);
9092
monthView.setLineColor(lineColor);
9193
monthView.setOffset(offset);
9294
layout.addView(monthView);
@@ -102,6 +104,7 @@ protected View initContentView() {
102104
dayView.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
103105
dayView.setTextSize(textSize);
104106
dayView.setTextColor(textColorNormal, textColorFocus);
107+
dayView.setLineVisible(lineVisible);
105108
dayView.setLineColor(lineColor);
106109
dayView.setOffset(offset);
107110
layout.addView(dayView);

WheelPicker/src/main/java/cn/qqtheme/framework/picker/OptionPicker.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ protected View initContentView() {
5050
optionView.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
5151
optionView.setTextSize(textSize);
5252
optionView.setTextColor(textColorNormal, textColorFocus);
53+
optionView.setLineVisible(lineVisible);
5354
optionView.setLineColor(lineColor);
5455
optionView.setOffset(offset);
5556
layout.addView(optionView);

WheelPicker/src/main/java/cn/qqtheme/framework/picker/TimePicker.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ protected View initContentView() {
4646
hourView.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
4747
hourView.setTextSize(textSize);
4848
hourView.setTextColor(textColorNormal, textColorFocus);
49+
hourView.setLineVisible(lineVisible);
4950
hourView.setLineColor(lineColor);
50-
hourView.setOffset(offset);
5151
layout.addView(hourView);
5252
TextView hourTextView = new TextView(activity);
5353
hourTextView.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
@@ -61,6 +61,7 @@ protected View initContentView() {
6161
minuteView.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
6262
minuteView.setTextSize(textSize);
6363
minuteView.setTextColor(textColorNormal, textColorFocus);
64+
minuteView.setLineVisible(lineVisible);
6465
minuteView.setLineColor(lineColor);
6566
minuteView.setOffset(offset);
6667
layout.addView(minuteView);

WheelPicker/src/main/java/cn/qqtheme/framework/picker/WheelPicker.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public abstract class WheelPicker extends ConfirmPopup<View> {
1818
protected int textColorNormal = WheelView.TEXT_COLOR_NORMAL;
1919
protected int textColorFocus = WheelView.TEXT_COLOR_FOCUS;
2020
protected int lineColor = WheelView.LINE_COLOR;
21+
protected boolean lineVisible = true;
2122
protected int offset = WheelView.OFF_SET;
2223

2324
public WheelPicker(Activity activity) {
@@ -37,6 +38,10 @@ public void setTextColor(int textColor) {
3738
this.textColorFocus = textColor;
3839
}
3940

41+
public void setLineVisible(boolean lineVisible) {
42+
this.lineVisible = lineVisible;
43+
}
44+
4045
public void setLineColor(int lineColor) {
4146
this.lineColor = lineColor;
4247
}

WheelPicker/src/main/java/cn/qqtheme/framework/widget/WheelView.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import java.util.List;
2424

2525
/**
26-
* 基于原版修改:可设置颜色、设置文字大小、去掉回弹阴影、修正以便支持联动效果
26+
* 基于原版修改:可设置颜色、设置文字大小、分隔线是否可见、去掉回弹阴影、修正以便支持联动效果
2727
*
2828
* @author 李玉江[QQ:1023694760]
2929
* @version 2015-12-17
@@ -59,6 +59,7 @@ public class WheelView extends ScrollView {
5959
private int textColorNormal = TEXT_COLOR_NORMAL;
6060
private int textColorFocus = TEXT_COLOR_FOCUS;
6161
private int lineColor = LINE_COLOR;
62+
private boolean lineVisible = true;
6263

6364
public WheelView(Context context) {
6465
super(context);
@@ -242,6 +243,11 @@ public void setBackgroundDrawable(Drawable background) {
242243
Log.d(TAG, "viewWidth: " + viewWidth);
243244
}
244245

246+
// FIXME: 2015/12/22 可设置分隔线是否可见
247+
if (!lineVisible){
248+
return;
249+
}
250+
245251
if (null == paint) {
246252
paint = new Paint();
247253
paint.setColor(lineColor);
@@ -341,6 +347,14 @@ public void setTextColor(@ColorInt int textColor) {
341347
this.textColorFocus = textColor;
342348
}
343349

350+
public boolean isLineVisible() {
351+
return lineVisible;
352+
}
353+
354+
public void setLineVisible(boolean lineVisible) {
355+
this.lineVisible = lineVisible;
356+
}
357+
344358
public int getLineColor() {
345359
return lineColor;
346360
}

screenshots/chinesezodiac.gif

113 KB
Loading

screenshots/time.gif

-12.3 KB
Loading

0 commit comments

Comments
 (0)