Skip to content

Commit 1892e9d

Browse files
author
liuhuaibing
committed
Merge branch 'dev' of https://github.com/luiing/StackViewLayout into dev
2 parents b104c96 + b16459b commit 1892e9d

5 files changed

Lines changed: 89 additions & 140 deletions

File tree

README.md

Lines changed: 3 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,12 @@
1-
# android-pile-layout
2-
An abnormal horizontal ListView-like pile layout.
1+
# StackViewLayout
2+
**An swip StackViewLayout,support left and right.**
33

44
### captured images
5-
The following pictures were captured earlier. Since the source code and the outputted-apk have changed some params, you will have a different UI when you directly run the code or install the apk file. Hope there has no confusions later. <br><br>
6-
<img src="capture/capture1.gif" width="360" height="645"/> <img src="capture/capture2.gif" width="360" height="645"/>
75

8-
### design
9-
Recently I have seen this kind of UI design, and at the first sight I was trying to implement it by using RecyclerView's LayoutManager. Unfortunately, I am unable to contrust a clear Math model while sliding the PileView. After several tries, I gave up LayoutManager, and find another way for this implementation. If you make LayoutManager works well for this UI design, please tell me later.
106

11-
### how to use
12-
1. declare PileLayout in your xml file
13-
``` xml
14-
<com.stone.pile.libs.PileLayout
15-
android:id="@+id/pileLayout"
16-
android:layout_width="match_parent"
17-
android:layout_height="wrap_content"
18-
android:paddingBottom="5dp"
19-
android:paddingTop="5dp"
20-
pile:displayCount="1.5"
21-
pile:interval="10dp"
22-
pile:scaleStep="0.22"
23-
pile:widthHeightRate="1.22" />
24-
```
25-
Meanwhile, pileLayout is able to be customized by these 4 params:
26-
27-
|name|format|description|
28-
|:---:|:---:|:---:|
29-
| interval | dimension |items-margin each other
30-
| sizeRatio | float |each item's height/witdth
31-
| scaleStep | float |size scale step when needed
32-
| displayCount | float |number of items that may display
33-
34-
2. in Java files:
35-
``` java
36-
pileLayout = (PileLayout) findViewById(R.id.pileLayout);
37-
pileLayout.setAdapter(new PileLayout.Adapter() {
38-
@Override
39-
public int getLayoutId() {
40-
// item's layout resource id
41-
return R.layout.item_layout;
42-
}
43-
44-
@Override
45-
public void bindView(View view, int position) {
46-
ViewHolder viewHolder = (ViewHolder) view.getTag();
47-
if (viewHolder == null) {
48-
viewHolder = new ViewHolder();
49-
viewHolder.imageView = (ImageView) view.findViewById(R.id.imageView);
50-
view.setTag(viewHolder);
51-
}
52-
// recycled view bind new position
53-
}
547

55-
@Override
56-
public int getItemCount() {
57-
// item count
58-
return dataList.size();
59-
}
60-
61-
@Override
62-
public void displaying(int position) {
63-
// right displaying the left biggest itemView's position
64-
}
65-
66-
@Override
67-
public void onItemClick(View view, int position) {
68-
// on item click
69-
}
70-
});
71-
```
8+
### how to use
729

73-
### demo apk
74-
[download](capture/app-debug.apk)
7510

7611
## License
7712

demo/src/main/AndroidManifest.xml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,32 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.uis.stackview.demo">
44

5+
<uses-permission android:name="android.permission.INTERNET" />
6+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
7+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
8+
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
9+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
10+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
11+
512
<application
613
android:allowBackup="true"
714
android:hardwareAccelerated="true"
815
android:icon="@mipmap/ic_launcher"
916
android:label="@string/app_name"
10-
android:largeHeap="true"
1117
android:supportsRtl="true"
1218
android:theme="@style/AppTheme">
13-
<activity android:name=".activity.MainActivity">
19+
<activity android:name=".activity.MainActivity"
20+
android:screenOrientation="portrait"
21+
>
1422
<intent-filter>
1523
<action android:name="android.intent.action.MAIN" />
1624

1725
<category android:name="android.intent.category.LAUNCHER" />
1826
<action android:name="android.intent.action.VIEW"/>
1927
</intent-filter>
28+
2029
</activity>
2130
</application>
2231

2332

24-
<uses-permission android:name="android.permission.INTERNET" />
25-
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
26-
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
27-
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
28-
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
29-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
30-
3133
</manifest>

demo/src/main/java/com/uis/stackview/demo/activity/MainActivity.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
import android.content.Intent;
44
import android.net.Uri;
55
import android.os.Bundle;
6+
import android.util.Log;
67
import android.view.LayoutInflater;
78
import android.view.View;
89
import android.view.ViewGroup;
910
import android.widget.Toast;
1011

1112
import com.bumptech.glide.Glide;
13+
import com.google.gson.Gson;
1214
import com.uis.stackview.StackLayout;
1315
import com.uis.stackview.demo.R;
1416
import com.uis.stackview.demo.entity.ItemEntity;
@@ -44,7 +46,7 @@ protected void onCreate(Bundle savedInstanceState) {
4446
stackViewLayout.setAdapter(new StackLayout.StackAdapter() {
4547
@Override
4648
public View onCreateView(ViewGroup parent) {
47-
return LayoutInflater.from(parent.getContext()).inflate(R.layout.item_layout,parent,false);
49+
return LayoutInflater.from(parent.getContext()).inflate(R.layout.item_layout,null);
4850
}
4951

5052
@Override
@@ -55,7 +57,7 @@ public void onBindView(View view, int position) {
5557
viewHolder.imageView = view.findViewById(R.id.imageView);
5658
view.setTag(viewHolder);
5759
}
58-
//Log.e("xx","binderVH: " + position + ",data: " + new Gson().toJson(dataList.get(position)));
60+
Log.e("xx","binderVH: " + position + ",data: " + new Gson().toJson(dataList.get(position)));
5961
Glide.with(view.getContext())
6062
.load(dataList.get(position).getCoverImageUrl()).into(viewHolder.imageView);
6163
}

demo/src/main/res/layout/activity_main.xml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66
android:background="#fff"
77
android:orientation="vertical">
88
<include layout="@layout/stack_right"/>
9-
<androidx.recyclerview.widget.RecyclerView
10-
android:id="@+id/recyclerView"
11-
android:layout_width="match_parent"
12-
android:layout_height="match_parent">
13-
14-
</androidx.recyclerview.widget.RecyclerView>
159

1610
<Button android:id="@+id/bt_web"
1711
android:layout_width="match_parent"
@@ -26,4 +20,13 @@
2620
android:visibility="gone"
2721
/>
2822

23+
<androidx.recyclerview.widget.RecyclerView
24+
android:id="@+id/recyclerView"
25+
android:layout_width="match_parent"
26+
android:layout_height="match_parent">
27+
28+
</androidx.recyclerview.widget.RecyclerView>
29+
30+
31+
2932
</LinearLayout>

0 commit comments

Comments
 (0)