Skip to content

Latest commit

 

History

History
110 lines (83 loc) · 2.52 KB

README.md

File metadata and controls

110 lines (83 loc) · 2.52 KB

Android广告框

Preview 效果预览

AdBox Preview Gif

Usage 使用方法

  1. 引用AdBox Library

    在build.gradle中添加依赖

    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'cn.kanejin.adbox:library:1.0.4@aar'
  2. 在layout里定义AdBox

    <cn.kanejin.adbox.AdBox
        android:id="@+id/ad_box"
        android:layout_height="80dp"
        android:layout_width="match_parent"
        android:layout_alignParentBottom="true"
        custom:adbox_placeholder="@drawable/demo_ad_placeholder"
        custom:adbox_duration="500"
        custom:adbox_delay="3000"
        custom:adbox_loop="true"
        custom:adbox_autoPlay="true" />
    

    查看完整的示例代码

  3. 在Activity里设置Adapter和Listener

    mAdBox = (AdBox) findViewById(R.id.ad_box);
    
    DemoAdBoxAdpter adapter = new DemoAdBoxAdpter(this);
    
    mAdBox.setAdapter(adapter);
    
    mAdBox.setListener(new AdBoxListener() {
        @Override
        public void onAdShowStart(AdBox adBox, int position, AdItem ad) {
    
        }
    
        @Override
        public void onAdShowEnd(AdBox adBox, int position, AdItem ad) {
    
        }
    
        @Override
        public void onAdClick(AdBox adBox, int position, AdItem ad) {
            Toast.makeText(MainActivity.this, ad.getTitle(), Toast.LENGTH_SHORT).show();
        }
    });

    查看完整的示例代码

Attributes 参数说明

参数名类型默认值说明
adbox_placeholder reference   广告加载时的占位图片
adbox_duration integer 1000 广告切换动画时间, 单位ms
adbox_delay integer 5000 广告停留时间, 单位ms
adbox_loop boolean true 是否循环播放
adbox_autoPlay boolean true 是否自动播放

License 许可

MIT

See Also 参阅

TextSlider