Banner展示手动滑动、自动播放

一、需求

在一个页面顶部展示多图,横向轮播,也即是通俗意义的Banner。需求细节解析:

1,同一个位置,展示不同的内容,包含展示图片、标题、内容描述【内容切换】;

2,因为同一个位置展示,需要有标示,告知用户当前所在的位置;【位置标识】;

3,便于内容的全部展示且不拒绝用户的主动操作,需要自动轮播与手动滑动处理相结合;【手动自动】;

4,当前位置内容可变,需要兼容多种模式【特值处理】;


二、实现思路

实现功能,一般通过现有控件,加以事件控制而达到目标。在基本实现上,可以通过抽取组合,形成自定控件。

基本实现:

1,选择ViewPager,基本已兼容大部分功能;

2,制作定位标志,标识当前所处位置;

3,再实现定时任务,达到各个页面的自动切换;


三、具体实现

1,xml文件

<FrameLayout
        android:layout_width="match_parent"
        android:layout_height="210dp">

        <android.support.v4.view.ViewPager
            android:id="@+id/vp"
            android:layout_width="match_parent"
            android:layout_height="210dp" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:background="@mipmap/shadow_article">

            <TextView
                android:id="@+id/tv_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_above="@+id/author_layout"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:maxLines="2"
                android:text="标题"
                android:textColor="@color/white"
                android:textSize="18sp" />

            <RelativeLayout
                android:id="@+id/author_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_marginLeft
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

壹叁零壹

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值