Skip to content

Commit

Permalink
优化选择器标题设置
Browse files Browse the repository at this point in the history
  • Loading branch information
liyujiang-gzu committed Sep 26, 2021
1 parent e07a57d commit ea6657a
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 17 deletions.
4 changes: 3 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# 更新日志

- 优化选择器设置标题设置,避免设置不生效问题;
## 4.0.1 - 2021.09.26

- 优化选择器标题设置,避免设置不生效问题;

## 4.0.0 - 2021.09.18

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,24 @@ private void maybeBuildEllipseButton() {
}
}

@Override
public void setTitle(@Nullable CharSequence title) {
if (titleView != null) {
titleView.setText(title);
} else {
super.setTitle(title);
}
}

@Override
public void setTitle(int titleId) {
if (titleView != null) {
titleView.setText(titleId);
} else {
super.setTitle(titleId);
}
}

@CallSuper
@Override
public void onClick(View v) {
Expand Down
48 changes: 32 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ data.add(new GoodsCategoryBean(4, "医疗保健"));
data.add(new GoodsCategoryBean(5, "酒水饮料"));
data.add(new GoodsCategoryBean(6, "图书音像"));
OptionPicker picker = new OptionPicker(this);
picker.setTitle("货物分类");
picker.setBodyWidth(140);
picker.getWheelView().setIndicatorColor(0xFFFF0000);
picker.getWheelView().setTextColor(0xFFFF00FF);
Expand Down Expand Up @@ -202,33 +203,49 @@ picker.show();
### 在 XML 中

```xml
<com.github.gzuliyujiang.wheelview.widget.WheelView android:id="@+id/wheel_view"
android:layout_width="117dp" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" app:wheel_atmosphericEnabled="true"
app:wheel_curvedEnabled="true" app:wheel_curvedIndicatorSpace="4dp"
app:wheel_curvedMaxAngle="60" app:wheel_indicatorColor="#FF0081FF" app:wheel_itemSpace="50dp"
app:wheel_itemTextColor="#FF474747" app:wheel_itemTextColorSelected="#FF0081FF"
<com.github.gzuliyujiang.wheelview.widget.WheelView
android:id="@+id/wheel_view"
android:layout_width="117dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
app:wheel_atmosphericEnabled="true"
app:wheel_curvedEnabled="true"
app:wheel_curvedIndicatorSpace="4dp"
app:wheel_curvedMaxAngle="60"
app:wheel_indicatorColor="#FF0081FF"
app:wheel_itemSpace="50dp"
app:wheel_itemTextColor="#FF474747"
app:wheel_itemTextColorSelected="#FF0081FF"
app:wheel_itemTextSize="20sp" />
```

```xml
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<com.github.gzuliyujiang.wheelpicker.widget.OptionWheelLayout android:id="@+id/wheel_option"
android:layout_width="90dp" android:layout_height="150dp"
android:layout_gravity="center_horizontal" app:wheel_itemTextAlign="center" />

<com.github.gzuliyujiang.wheelpicker.widget.DateWheelLayout android:layout_width="120dp"
android:layout_height="150dp" android:layout_gravity="center_horizontal"
app:wheel_dateMode="month_day" app:wheel_dayLabel="" app:wheel_monthLabel="" />
<com.github.gzuliyujiang.wheelpicker.widget.OptionWheelLayout
android:id="@+id/wheel_option"
android:layout_width="90dp"
android:layout_height="150dp"
android:layout_gravity="center_horizontal"
app:wheel_itemTextAlign="center" />

<com.github.gzuliyujiang.wheelpicker.widget.DateWheelLayout
android:layout_width="120dp"
android:layout_height="150dp"
android:layout_gravity="center_horizontal"
app:wheel_dateMode="month_day"
app:wheel_dayLabel=""
app:wheel_monthLabel="" />

...

</LinearLayout>
```

### 定制样式
### 自定义样式

#### 全局配置所有选择器样式及配色

Expand All @@ -251,7 +268,6 @@ public class DemoApp extends Application {
#### `app/.../res/values/styles.xml`中重写`WheelDefault`覆盖

```xml

<style name="WheelDefault">
<item name="wheel_visibleItemCount">5</item>
<item name="wheel_itemTextAlign">center</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public void onOptionBean(View view) {
data.add(new GoodsCategoryBean(5, "酒水饮料"));
data.add(new GoodsCategoryBean(6, "图书音像"));
OptionPicker picker = new OptionPicker(this);
picker.setTitle("货物分类");
picker.setBodyWidth(140);
picker.getWheelView().setIndicatorColor(0xFFFF0000);
picker.getWheelView().setTextColor(0xFFFF00FF);
Expand Down

0 comments on commit ea6657a

Please sign in to comment.