ReplaceLayout
ICON
交替布局儡遮,配合TabStrip使用奋岁,達到伴隨ViewPager動作而進行改變的效果嚼酝,繼承自FrameLayout妄均,通過設(shè)置ReplaceAdapter來完成管理子項View的變化毙驯,并通過move(int, int, float)方法和moveTo(int)方法達到變化的效果倒堕。
預(yù)覽
Screenshots
要求
無
鏈接
使用
- 基本布局
<am.widget.replacelayout.ReplaceLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
- 基本代碼
replaceLayout = (ReplaceLayout) findViewById(id);
replaceLayout.setAdapter(adapter);
replaceLayout.moveTo(correct);
replaceLayout.move(correct, next, offset);
注意
- 繼承自FrameLayout,僅修改必要的觸摸攔截爆价,不建議通過xml方式在其內(nèi)部添加View
- 僅有設(shè)置ReplaceAdapter并實現(xiàn)其中的變化方法才能實現(xiàn)子View變化效果
- move(int, int, float)中最后一個參數(shù)為-1~1的偏移值
- 清楚移動方向可使用moveLeft(int, int, float)及moveRight(int, int, float)