Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
goyourfly committed Nov 27, 2017
1 parent c7c4b53 commit 7097883
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
72 changes: 72 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,73 @@
# PaperView

##### PaperView 是一个自定义的View,它就像一张纸折叠和展开

### Demo

<img src="./screenshot/PaperView.gif" width="240"/>

### Compile

````java
compile 'com.goyourfly:paperview:1.0'
````

### Usage

##### 1.在布局中声明
````xml
<com.goyourfly.library.paper_view.PaperView
android:id="@+id/paperView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
app:paper_bg_color="#fff"
app:paper_duration="1000">

<!--展开的布局-->
<include layout="@layout/item_large" />
<!--收起的布局-->
<include layout="@layout/item_small" />

</com.goyourfly.library.paper_view.PaperView>
````
| 参数 | 类型 | 说明 | 默认值 |
|:-:|:-:|:-:|:-:|
| paper\_duration | integer | 动画总时长 | 2000 |
| paper\_bg\_color | color | 纸片背景色 | #FFF |

##### 2.在代码中触发

###### 2.1 展开和折叠
````java
// 折叠卡片
paperView.fold(changed:Boolean)

// 展开卡片
paperView.unfold(changed:Boolean)
````

###### 2.2 监听状态变化

````java
paperView.setStateChangedListener(object:PaperView.OnFoldStateChangeListener{
// 折叠
override fun onFold() {}
// 展开
override fun onUnfold() {}
})
````

### License
````java
Copyright 2017-present, GaoYufei
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
````
2 changes: 2 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@
app:paper_bg_color="#fff"
app:paper_duration="1000">

<!--展开的布局-->
<include layout="@layout/item_large" />

<!--收起的布局-->
<include layout="@layout/item_small" />

</com.goyourfly.library.paper_view.PaperView>
Expand Down
8 changes: 8 additions & 0 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

ext {
PUBLISH_GROUP_ID = 'com.goyourfly'
PUBLISH_ARTIFACT_ID = 'paperview'
PUBLISH_VERSION = '1.0'
}

android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
Expand Down Expand Up @@ -38,3 +44,5 @@ dependencies {
repositories {
mavenCentral()
}

apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle'
Binary file added screenshot/PaperView.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7097883

Please sign in to comment.