Skip to content

Commit

Permalink
1.update readme
Browse files Browse the repository at this point in the history
2.fix a bug about webview
  • Loading branch information
w446108264 committed Apr 16, 2016
1 parent 69caaa8 commit a9a1e4c
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 38 deletions.
63 changes: 29 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
ScrollableLayout
======================

An Android library supports sticking the navigator on the top when ItemView scrolls.
> j.s 🇨🇳
fork and change on [https://github.com/cpoopc/ScrollableLayout](https://github.com/cpoopc/ScrollableLayout)

scrolling is not smooth, especially on some models .than
[w446108264/StickHeaderLayout](https://github.com/w446108264/StickHeaderLayout)

gif

![Art](https://github.com/w446108264/ScrollableLayout/raw/master/output/little.gif)
easy to add a headview for any view and supports sticking the navigator on the top when ItemView scrolls.

![Art](https://github.com/w446108264/ScrollableLayout/raw/master/output/show.gif)
fork and change on [https://github.com/cpoopc/ScrollableLayout](https://github.com/cpoopc/ScrollableLayout)

scrolling is not smooth, especially on some models .

![Art](https://github.com/w446108264/ScrollableLayout/raw/master/output/p2.jpg) ![Art](https://github.com/w446108264/ScrollableLayout/raw/master/output/p4.jpg)
another choice 「 [w446108264/StickHeaderLayout](https://github.com/w446108264/StickHeaderLayout)

![Art](https://github.com/w446108264/ScrollableLayout/raw/master/output/p5.jpg) ![Art](https://github.com/w446108264/ScrollableLayout/raw/master/output/p6.jpg)


# Features

* API > 11
* Support RecyclerView, ScrollView, ListView, WebView.
* Support ViewPager, RecyclerView, ScrollView, ListView, WebView
* Support pulltoRefresh and loadmore
* Support dynamic headview
* Easy to add a headview for any view

![Art](https://github.com/w446108264/ScrollableLayout/raw/master/output/show.gif)


# Screen Recrod

<img src="https://github.com/w446108264/ScrollableLayout/raw/master/output/p2.jpg" width="24%" />
<img src="https://github.com/w446108264/ScrollableLayout/raw/master/output/p4.jpg" width="24%" />
<img src="https://github.com/w446108264/ScrollableLayout/raw/master/output/p5.jpg" width="24%" />
<img src="https://github.com/w446108264/ScrollableLayout/raw/master/output/p6.jpg" width="24%" />

# Samples

You can [download a sample APK](https://github.com/w446108264/ScrollableLayout/raw/master/output/simple.apk)
Expand All @@ -49,19 +52,15 @@ and:

```xml
dependencies {
compile 'com.github.w446108264:ScrollableLayout:1.0.2'
compile 'com.github.w446108264:ScrollableLayout:1.0.3'
}
```
--


# Usage

simple to your proejct

### Layout
# Sample Usage

the frist childview will be ticked on the top.


```xml
<com.scrollablelayout.ScrollableLayout
Expand All @@ -70,6 +69,7 @@ the frist childview will be ticked on the top.
android:layout_height="match_parent"
android:orientation="vertical">

<!--the frist childview will follow the scrollview scroll.-->
<TextView
android:layout_width="match_parent"
android:layout_height="200dp"
Expand All @@ -78,6 +78,9 @@ the frist childview will be ticked on the top.
android:textColor="#fff"
android:text="header" />

<!--the second childview will be a navigator.
it will be sticking on the top when ItemView scrolls,
it's not necessary to add if you don't want-->
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
Expand All @@ -86,6 +89,7 @@ the frist childview will be ticked on the top.
android:textColor="#fff"
android:text="navigationbar" />

<!--ScrollView support ViewPager, RecyclerView, ScrollView, ListView, WebView-->
<ListView
android:id="@+id/vp_scroll"
android:layout_width="match_parent"
Expand All @@ -95,20 +99,11 @@ the frist childview will be ticked on the top.
</com.scrollablelayout.ScrollableLayout>
```

### Simple

```java

sl_root = (ScrollableLayout) findViewById(R.id.sl_root);
listview = (ListView) findViewById(R.id.vp_scroll);
int size = 100;
String[] stringArray = new String[size];
for (int i = 0; i < size; ++i) {
stringArray[i] = ""+i;
}
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, stringArray);
listview.setAdapter(adapter);
sl_root.getHelper().setCurrentScrollableContainer(listview);
// please see the demo
sl_root = (ScrollableLayout) findViewById(R.id.sl_root);
listview = (ListView) findViewById(R.id.vp_scroll);
sl_root.getHelper().setCurrentScrollableContainer(listview);

```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
Expand Down Expand Up @@ -48,6 +50,8 @@ public class MainActivity extends AppCompatActivity implements ViewPager.OnPageC

@Override
protected void onCreate(Bundle savedInstanceState) {
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.scrollablelayout.simple;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
Expand Down Expand Up @@ -34,5 +37,16 @@ private void initView() {
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, stringArray);
listview.setAdapter(adapter);
sl_root.getHelper().setCurrentScrollableContainer(listview);

TextView tv = (TextView) findViewById(R.id.tv_right);
tv.setText("Github");
tv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Uri uri = Uri.parse("https://github.com/w446108264/ScrollableLayout");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:layout_centerHorizontal="true"
android:text="https://github.com/w446108264"
android:text="https://github.com/w446108264/ScrollableLayout"
android:textColor="#7e7e7e"
android:textSize="13sp" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.annotation.SuppressLint;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
Expand Down Expand Up @@ -106,8 +105,8 @@ private static boolean isScrollViewTop(ScrollView scrollView) {
return false;
}

private static boolean isWebViewTop(WebView scrollView){
if(scrollView != null) {
private static boolean isWebViewTop(WebView scrollView) {
if (scrollView != null) {
int scrollViewY = scrollView.getScrollY();
return scrollViewY <= 0;
}
Expand All @@ -128,6 +127,8 @@ public void smoothScrollBy(int velocityY, int distance, int duration) {
((ScrollView) scrollableView).fling(velocityY);
} else if (scrollableView instanceof RecyclerView) {
((RecyclerView) scrollableView).fling(0, velocityY);
} else if (scrollableView instanceof WebView) {
((WebView)scrollableView).flingScroll(0,velocityY);
}
}
}
Binary file removed output/little.gif
Binary file not shown.
Binary file modified output/show.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added output/slow.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 a9a1e4c

Please sign in to comment.