美文网首页
ReplaceLayout-交替布局

ReplaceLayout-交替布局

作者: AlexMofer | 来源:发表于2016-09-02 15:42 被阅读0次

    ReplaceLayout

    ICON

    交替布局,配合TabStrip使用,达到伴随ViewPager动作而进行改变的效果,继承自FrameLayout,通过设置ReplaceAdapter来完成管理子项View的变化,并通过move(int, int, float)方法和moveTo(int)方法达到变化的效果。

    预览

    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方式在其内部添加View
    • 仅有设置ReplaceAdapter并实现其中的变化方法才能实现子View变化效果
    • move(int, int, float)中最后一个参数为-1~1的偏移值
    • 清楚移动方向可使用moveLeft(int, int, float)及moveRight(int, int, float)

    相关文章

      网友评论

          本文标题:ReplaceLayout-交替布局

          本文链接:https://www.haomeiwen.com/subject/dwzhettx.html