StackLinearLayout-Android

Smart linear layout for android

Make custom linear layout for android.
Suport two mode : 
  * Stack layout.
  * Wheel layout.

Using :

  • Import module SmartLayoutManager to project.
  • Set minHeight for RecyclerView

 <androidx.recyclerview.widget.RecyclerView
         android:id="@+id/recyclerView
         app:layout_constraintStart_toStartOf="parent"
         android:background="@color/cardview_dark_background"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintTop_toTopOf="parent"
         android:layout_width="match_parent"
         android:orientation="vertical"
         tools:itemCount="10"
         tools:listitem="@layout/item_view"
         android:minHeight="100dp"
         android:layout_height="wrap_content"/>  
                                             
 ```

* Using constructor create mode :
 - Stack :

  val smartLayoutStack = SmartLayoutManager(orientation = SmartLayoutManager.VERTICAL, itemVisible = 3, isStackLayout = true, offset = 10, modeStack = SmartLayoutManager.STACK_RIGHT)
  
 - Wheel :
 
  val smartLayout = SmartLayoutManager(orientation = SmartLayoutManager.HORIZONTAL, itemVisible = 3, isCircleLayout = true, offset = 10)
  
 With : 
   - orientation = HORIZONTAL | VERTICAL
   - itemVisible : Items show on top or bottom with one center item. Ex : 2 have show 2 items in top, 1 center, 2 items on bottom.
   - isStackLayout : Using stack layout.
   - isCircleLayout : Using circle layout.
   - offset : Adj margin of item.
   - modeStack : STACK_TOP | STACK_BOTTOM | STACK_LEFT | STACK_RIGHT
* Create new class and extent class ZoomPostLayoutListener or using ZoomPostLayoutListener for implement zoom, alpha to view.


Full code : 

```kotlin

     // If isCircleLayout = false, it same normal linear layout, but have center item
     val smartLayout = SmartLayoutManager(orientation = SmartLayoutManager.HORIZONTAL, itemVisible = 3, isCircleLayout = true, offset = 10)
     smartLayout.addOnItemSelectionListener(object : OnCenterItemSelectionListener {
         override fun onCenterItemChanged(adapterPosition: Int) {
             val item = adapterViewItem.dataList[adapterPosition]
             Log.e("Main", item.title)
         }
     })

     dataBinding.recyclerView.addOnScrollListener(CenterScrollListener())
     dataBinding.recyclerView.setHasFixedSize(true)
     dataBinding.recyclerView.adapter = adapterViewItem
     dataBinding.recyclerView.layoutManager = smartLayout
     // You can extent class ZoomPostLayoutListener for modify item size and alpha
     smartLayout.configPostListener(ZoomPostLayoutListener(0.08f, transformAlpha = false))
     

Ex :

Stack layout :

Top

Screenshot 2022-12-27 at 13 32 23

Bottom :

Screenshot 2022-12-27 at 13 50 24

Left :

Screenshot 2022-12-27 at 13 54 58

Right :

Screenshot 2022-12-27 at 13 55 58

Circle Layout : true

Screenshot 2022-12-27 at 13 34 54

Screenshot 2022-12-27 at 13 35 06

Circle Layout : false

Screenshot 2022-12-27 at 13 35 54

GitHub

View Github