Laya 滑動切換的ViewStack

2022-06-24 15:57:11 字數 2273 閱讀 8588

@ixenos 2020-10-29 11:08:36

1.檢視viewstack原始碼,發現只是個簡單的visible切換,我們繼承修改一下,實現緩動切換

1/**

2* 使用運動切換的viewstack

3* @author ixenos 2020-10-14 18:29:224*

5*/6public

class cviewstack extends

viewstack720

21 override public

function

set selectedindex(value:int):void

else35}

36}3738/**

39* @private

40* @param index 需要設定的物件的索引。

41* @param selected 表示物件的選中狀態。

42*/

43 protected function setselectmotion(index:int, selected:boolean, dirv:int):void

5051

if(!selected)

5455

var outsidex:number = (dirv>0?1:-1) *width;

56var motiontime:number = 500;

5758 item.visible = true;59

vart:tween;

60if

(selected), motiontime, ease.circout);

63 }else

, motiontime, ease.circout, new handler(this

, com));66}

6768

_tweenstack.push(t);

6970

function com():void

7374}75

}7677/**78

* items 表層事件清洗

79*/

80private

function disposeitems():void87}

8889

if(_items && _items.length>0)

95laya.timer.clearall(item);

96tween.clearall(item);97}

98}99}

100101

/**@inheritdoc

*/102 override public

function destroy(destroychild:boolean = true):void

2.業務偽**

viewstack業務

1

private

function addevent():void26

}78private

function onviewstackdown(e:event = null):void913

14private

function onviewstackup(laststagex:number, e:event = null):void

1526}27

else

if(dirv < -20)

2833}34

}3536private

function delevent():void

37

viewstack搭配tab

1             lui.listtab.selectenable = false

;2 lui.listtab.selecthandler = handler.create(this, listtabselect, null, false

);3 lui.listtab.selectedindex = 1;45

private

function listtabselect(index:int):void613

14//

切換頁面

15var dat:* =lui.listtab.getitem(index);

16 lui.viewstack.selectedindex =index;

17 }

滑動切換Activity

在dependencies中加入下面一句,就可以引入開源庫到當前專案 compile com.r0adkll slidableactivity 2.0.3 需要準備兩個activity,唯一需要注意的是activity的theme需要重寫下面的 name android windowistransl...

Android Fragment滑動切換

1,因為要進行滑動,所以中文在布局中就進行viewpager布局 android id id vp container android layout width match parent android layout height match parent android.support.v4.vi...

uview 滑動切換

html template view class content u swiper list list2 keyname image showtitle autoplay false circular u swiper u modal show show title test confirmtext...