android-pile-layout
介绍:
横向滚动的卡片堆叠布局
运行效果:
使用说明:
- 在xml文件中定义 PileLayout
<com.stone.pile.libs.PileLayout
android:id="@+id/pileLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingTop="5dp"
pile:displayCount="1.5"
pile:interval="10dp"
pile:scaleStep="0.22"
pile:widthHeightRate="1.22" />
可以用这四个参数自定义pileLayout:
name | format | description |
---|---|---|
interval | dimension | items-margin each other |
sizeRatio | float | each item's height/witdth |
scaleStep | float | size scale step when needed |
displayCount | float | number of items that may display |
- Java 文件中:
pileLayout = (PileLayout) findViewById(R.id.pileLayout);
pileLayout.setAdapter(new PileLayout.Adapter() {
@Override
public int getLayoutId() {
// item's layout resource id
return R.layout.item_layout;
}
@Override
public void bindView(View view, int position) {
ViewHolder viewHolder = (ViewHolder) view.getTag();
if (viewHolder == null) {
viewHolder = new ViewHolder();
viewHolder.imageView = (ImageView) view.findViewById(R.id.imageView);
view.setTag(viewHolder);
}
// recycled view bind new position
}
@Override
public int getItemCount() {
// item count
return dataList.size();
}
@Override
public void displaying(int position) {
// right displaying the left biggest itemView's position
}
@Override
public void onItemClick(View view, int position) {
// on item click
}
});
demo apk
已下载
0