使用VerticalBannerView实现垂直轮播广告(仿淘宝头条)

本文介绍了一个开源项目VerticalBannerView,它是一个模仿淘宝APP首页轮播头条的自定义控件,支持自由定义内容,使用方式类似ListView/RecyclerView。通过详细步骤展示了如何添加依赖、布局、实现Adapter以及源码分析,提供了实现垂直轮播广告的完整流程。
摘要由CSDN通过智能技术生成
VerticalBannerView是一个仿淘宝APP首页轮播头条的自定义控件。
特性:
1.可自由定义展示的内容。
2.使用方式类似ListView/RecyclerView。
3.可为当前显示的内容添加各种事件,比如点击打开某个页面等。

VerticalBannerView开源项目地址:
https://github.com/guojunustb/VerticalBannerView

运行效果图:


一、项目使用

(1).添加项目依赖。
dependencies {
    compile 'com.github.Rowandjj:VerticalBannerView:1.0'
}

(2).添加布局。
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical"
    android:orientation="horizontal">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="5dp"
        android:text="淘宝头条"
        android:textStyle="bold"/>

    <View
        android:layout_width="1dp"
        android:layout_height="40dp"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:background="#cccccc"/>

    <com.taobao.library.VerticalBannerView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/banner"
        android:layout_width="wrap_content"
        android:layout_height="36dp"
        app:animDuration="900"
        app:gap="2000"/>
</LinearLayout>

(3).实现Adapter。
public class SampleAdapter extends BaseBannerAdapter<Model> {
    private List<Model> mDatas;

    public SampleAdapter01(List<Model> datas) {
        super(datas);
    }

    &
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值