导入依赖
implementation 'com.recker.flybanner:flybanner:1.3'
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.recker.flybanner.FlyBanner
android:layout_width="match_parent"
android:layout_height="250dp"
android:id="@+id/fly_bannner"
></com.recker.flybanner.FlyBanner>
</LinearLayout>
package com.example.myapplication4;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import com.recker.flybanner.FlyBanner;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import cn.bingoogolapple.bgabanner.BGABanner;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FlyBanner b = findViewById(R.id.banner);
ImageView iamge1 = findViewById(R.id.image1);
List<String> list = new ArrayList<>();
list.add("http://attach.bbs.miui.com/forum/201303/16/173716jzszx8vbbb0z9o4k.jpg");
list.add("http://pic.58pic.com/58pic/13/16/42/18F58PIChTy_1024.jpg");
list.add("http://pic28.photophoto.cn/20130929/0034034819144555_b.jpg");
for (int i = 0; i <list.size(); i++) {
list.get(i);
}
b.setImagesUrl(list);
}
}