Skip to content

Commit

Permalink
add usage sample in README
Browse files Browse the repository at this point in the history
  • Loading branch information
LuMeng committed Oct 21, 2016
1 parent 7efd135 commit 8259b45
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 5 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
Expand Down Expand Up @@ -45,4 +44,4 @@ captures/
.DS_Store

# Personal
app/config.properties
app/config.properties
66 changes: 63 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,70 @@
### Preview

#### 1. sample_ListView
![sample_list](./art/sample_list.gif)
<img src=./art/sample_list.gif width=300/>

#### 2. sample_RecyclerView
![sample_recycler](./art/sample_recycler.gif)
<img src=./art/sample_recycler.gif width=300/>

#### 3. sample_ScrollView
![sample_recycler](./art/sample_scroll.gif)
<img src=./art/sample_scroll.gif width=300/>

### Usage
- Add `AlphaLayout` widget in your layout

```xml
<com.alhpalayout.AlphaLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/alpha_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:headerLayout="@layout/layout_header"
app:transparent_distance="150dp"
tools:context="com.alphalayout.activity.ListSampleActivity">

<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@null"
android:dividerHeight="0dp" />

</com.alhpalayout.AlphaLayout>
```

- implements AlphaLayout.OnRefreshListener in your `Activity`

```java
@Override
public void onRefresh() {
alphaLayout.postDelayed(new Runnable() {
@Override
public void run() {
alphaLayout.setRefreshing(false);
}
}, REFRESH_DELAY);
}

@Override
public void onScroll(int direction, float percent) {
if (direction == AlphaLayout.DIRECTION_DOWN) {
ViewCompat.setAlpha(alphaLayout.getHeaderLayout(), 1.0f - percent);
} else {
alphaLayout.getHeaderLayout().getBackground().setAlpha((int) (255 * percent));
mTitleView.getBackground().mutate().setAlpha((int) (255 * (1 - percent)));
}
}
```

### Attention
- You should use `AlphaScrollView` which been provided instead of `ScrollView`.
- I also provided `AlphaHeaderLayout` which can make good performance easily.

**See sample project for detail**

### Download Sample apk
#### 1. Fir.im
<img src=./art/fir_1.0.0_release.jpeg width=300 />
#### 2.download apk directly
[release_1.0.0_github.apk](./art/alpha_release-1/0/0-github.apk)
Binary file added art/alpha-release-1.0.0-github.apk
Binary file not shown.
Binary file added art/fir_1.0.0_release.jpeg
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 8259b45

Please sign in to comment.