Skip to content

Commit

Permalink
自述文档加入示例代码
Browse files Browse the repository at this point in the history
  • Loading branch information
liyujiang-gzu committed Jun 12, 2021
1 parent 4be964c commit de635a0
Showing 1 changed file with 87 additions and 1 deletion.
88 changes: 87 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,93 @@ dependencies {

## 用法示例

常见用法参阅 [demo](/app),建议拉取代码运行,对比查看实际效果。
常见用法请参阅 [demo](/app),高级用法请细读[源码](/WheelPicker)。强烈建议拉取代码运行,尝试修改 demo 对比查看实际效果以便加深理解。

### 在 Java 中

```groovy
OptionPicker picker = new OptionPicker(this);
picker.setBackgroundColor(true, 0xFFFFFFFF);
picker.setData("测试", "很长很长很长很长很长很长很长很长很长很长很长很长很长很长");
picker.setOnOptionPickedListener(this);
picker.getTitleView().setText("这是标题");
picker.getWheelView().setCyclicEnabled(true);
picker.getWheelView().setCurvedEnabled(true);
picker.getWheelView().setCurvedMaxAngle(60);
picker.show();
```

```groovy
AddressPicker picker = new AddressPicker(this);
picker.setAddressMode(AddressMode.PROVINCE_CITY_COUNTY);
picker.setDefaultValue("贵州省", "贵阳市", "观山湖区");
picker.setOnAddressPickedListener(this);
picker.show();
```

### 在 XML 中

```xml
<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.LinkageWheelLayout
android:id="@+id/wheel_linkage"
android:layout_width="match_parent"
android:layout_height="150dp"
app:wheel_curtainColor="#FFF1F1F1"
app:wheel_curtainEnabled="true"
app:wheel_indicatorEnabled="false" />

<com.github.gzuliyujiang.wheelpicker.widget.NumberWheelLayout
android:layout_width="90dp"
android:layout_height="150dp"
android:layout_gravity="center_horizontal"
app:wheel_curvedEnabled="true"
app:wheel_curvedMaxAngle="45"
app:wheel_label=""
app:wheel_maxNumber="30"
app:wheel_minNumber="10"
app:wheel_stepNumber="5"
app:wheel_visibleItemCount="7" />

<com.github.gzuliyujiang.wheelpicker.widget.DatimeWheelLayout
android:layout_width="match_parent"
android:layout_height="150dp"
app:wheel_dateMode="year_month_day"
app:wheel_indicatorColor="#FFEEEEEE"
app:wheel_indicatorSize="5dp"
app:wheel_timeMode="hour_12_no_second" />

<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.TimeWheelLayout
android:layout_width="95dp"
android:layout_height="150dp"
android:layout_gravity="center_horizontal"
app:wheel_curvedEnabled="true"
app:wheel_curvedMaxAngle="45"
app:wheel_hourLabel=":"
app:wheel_minuteLabel=":"
app:wheel_timeMode="hour_24_has_second" />

</LinearLayout>
```

## 效果预览

Expand Down

0 comments on commit de635a0

Please sign in to comment.