ReplaceLayout-交替布局

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)
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容