项目作者: xmuSistone

项目描述 :
An abnormal horizontal ListView-like pile layout with stretch and contraction effects.
高级语言: Java
项目地址: git://github.com/xmuSistone/AndroidPileLayout.git
创建时间: 2017-05-13T06:17:37Z
项目社区:https://github.com/xmuSistone/AndroidPileLayout

开源协议:

下载


android-pile-layout

An abnormal horizontal ListView-like pile layout.

captured images

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.


design

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.

how to use

  1. declare PileLayout in your xml file
    1. <com.stone.pile.libs.PileLayout
    2. android:id="@+id/pileLayout"
    3. android:layout_width="match_parent"
    4. android:layout_height="wrap_content"
    5. android:paddingBottom="5dp"
    6. android:paddingTop="5dp"
    7. pile:displayCount="1.5"
    8. pile:interval="10dp"
    9. pile:scaleStep="0.22"
    10. pile:widthHeightRate="1.22" ></com.stone.pile.libs.PileLayout>
    Meanwhile, pileLayout is able to be customized by these 4 params:
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
  1. in Java files:

    1. pileLayout = (PileLayout) findViewById(R.id.pileLayout);
    2. pileLayout.setAdapter(new PileLayout.Adapter() {
    3. @Override
    4. public int getLayoutId() {
    5. // item's layout resource id
    6. return R.layout.item_layout;
    7. }
    8. @Override
    9. public void bindView(View view, int position) {
    10. ViewHolder viewHolder = (ViewHolder) view.getTag();
    11. if (viewHolder == null) {
    12. viewHolder = new ViewHolder();
    13. viewHolder.imageView = (ImageView) view.findViewById(R.id.imageView);
    14. view.setTag(viewHolder);
    15. }
    16. // recycled view bind new position
    17. }
    18. @Override
    19. public int getItemCount() {
    20. // item count
    21. return dataList.size();
    22. }
    23. @Override
    24. public void displaying(int position) {
    25. // right displaying the left biggest itemView's position
    26. }
    27. @Override
    28. public void onItemClick(View view, int position) {
    29. // on item click
    30. }
    31. });

demo apk

download

License

  1. Copyright 2017, xmuSistone
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.