/TwoWayGallery

支持垂直水平两个方向,并能循环的Gallery

Primary LanguageJava

介绍

支持垂直水平两个方向,并能循环(后续添加)的Gallery,并且扩展实现了CoverFlow,支持对未选中Item进行缩放、透明度改变和层次覆盖感觉

TwoWayGallery

TwoWayGallery的使用和Gallery的一样,并在Gallery基础上增加了方向属性,支持垂直和水平方向,通过属性orientation修改,默认为水平方向

基本使用

//水平方向
...
<com.hellocsl.twowaygallery.TwoWayGallery
           android:id="@+id/gallery_vertical"
           android:layout_width="wrap_content"
           android:layout_height="match_parent"
           android:layout_gravity="center"
           app:orientation="horizontal"
           app:spacing="2dip"
           app:unselectedAlpha="0.7"
           />
...

//or 垂直方向
...
<com.hellocsl.twowaygallery.TwoWayGallery
           android:id="@+id/gallery_vertical"
           android:layout_width="wrap_content"
           android:layout_height="match_parent"
           android:layout_gravity="center"
           app:orientation="vertical"
           app:spacing="2dip"
           app:unselectedAlpha="0.7"
           />
...

支持循环模式

通过修改属性autoCycle来支持循环模式

注意:是否真正支持循环还需要根据实际情况来判断

例如:当外部数据量为3,而整个的TwoWayGallery有够容纳3个Item的空间,这样的情况下是不支持循环模式的

效果

Demo

CoverFlow

类似FancyCoverFlow,并且更有效率,不会不断地调用getChildStaticTransformation方法,显示效果为平铺,通过coverage属性修改层次覆盖属性

使用

...
<com.hellocsl.twowaygallery.flow.CoverFlow
          android:id="@+id/gallery_horizontal"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_gravity="center"
          app:coverage="0.2"
          app:orientation="horizontal"
          app:unselectedAlpha="0.7"
          app:unselectedScale="0.8"
          />
...
or
...
<com.hellocsl.twowaygallery.flow.CoverFlow
    android:id="@+id/gallery_vertical"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    app:orientation="vertical"
    app:spacing="2dip"
    app:unselectedAlpha="0.7"
    app:unselectedScale="0.8"
    />
...

效果

Demo