Java Code Examples for com.youth.banner.Banner#setIndicatorGravity()

The following examples show how to use com.youth.banner.Banner#setIndicatorGravity() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataBindingAdapter.java    From RvHelper with Apache License 2.0 6 votes vote down vote up
@BindingAdapter(value = {"data", "bannerListener"}, requireAll = false)
public static void setSlider(Banner banner, String data, OnBannerListener onBannerListener) {
    List<String> banners = new ArrayList<>();
    banners.add("https://res.darryring.com/activity/drSEM_storeLandingPage/temp/part04_banner01.jpg");
    banners.add("https://res.darryring.com/activity/drSEM_storeLandingPage/temp/part04_banner02.jpg");
    banners.add("https://res.darryring.com/activity/drSEM_storeLandingPage/temp/part04_banner03.jpg");
    banners.add("https://static.darryring.com/ueditor/2017-03-28/1490687105.jpg");

    banner.setAdapter(new ImageAdapter(banners));
    banner.setIndicator(new CircleIndicator(banner.getContext()));
    banner.setIndicatorSelectedColorRes(R.color.colorAccent);
    banner.setIndicatorNormalColorRes(android.R.color.white);
    banner.setIndicatorGravity(IndicatorConfig.Direction.LEFT);
    banner.setIndicatorSpace((int) BannerUtils.dp2px(20));
    banner.setIndicatorMargins(new IndicatorConfig.Margins((int) BannerUtils.dp2px(10)));
    banner.setIndicatorWidth(10, 20);
    //banner.addItemDecoration(new MarginItemDecoration((int) BannerUtils.dp2px(50)));
    //banner.setPageTransformer(new DepthPageTransformer());
    banner.setOnBannerListener(onBannerListener);
    //banner.addOnPageChangeListener(onBannerListener);
    banner.start();
}
 
Example 2
Source File: ThirdFragment.java    From myapplication with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化界面控件
 */
private void initView() {
    mImages.add(R.drawable.find_1);
    mImages.add(R.drawable.find_2);
    mImages.add(R.drawable.find_8);
    mImages.add(R.drawable.find_4);
    mImages.add(R.drawable.find_5);
    mImages.add(R.drawable.find_6);
    mImages.add(R.drawable.find_7);

    mTitles.add("既见公子,云胡不喜?");
    mTitles.add("我只想静静地,做个美男子。");
    mTitles.add("曾经的曾经,只剩期望...");
    mTitles.add("你那么美,爱我如何?");
    mTitles.add("夜,夜,夜...");
    mTitles.add("孩子,快点睡吧,明天还要抢票回家呢。");
    mTitles.add("天边美丽的火烧云啊,我的生活放荡,像条狗,像条流浪狗...");

    titleSearchIbtn = (ImageButton) view.findViewById(R.id.title_find_search_ibtn);
    titleSearchIbtn.setOnClickListener(ThirdFragment.this);

    nineGridView = (NineGridView) view.findViewById(R.id.find_nine_gridview);
    nineGridView.setAdapter(new NineGridViewAdapter(getActivity()));

    mBanner = (Banner) view.findViewById(R.id.banner);
    mBanner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE);
    mBanner.setBannerAnimation(Transformer.Default);
    mBanner.isAutoPlay(true);
    mBanner.setDelayTime(3000);
    mBanner.setIndicatorGravity(BannerConfig.CENTER);
    mBanner.setBannerTitles(mTitles);
    mBanner.setImageLoader(new GlideImageLoader());
    mBanner.setImages(mImages);
    mBanner.start();
    mBanner.setOnBannerClickListener(this);
}
 
Example 3
Source File: HomeFragment.java    From HomeApplianceMall with MIT License 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_home, container, false);
    canRefresh = true;
    first = true;
    application = (MyApplication)getActivity().getApplication();
    gridView = (MyGridView) v.findViewById(R.id.GridView_fhome);
    gridViewToday = (MyGridView) v.findViewById(R.id.GridView_fhome_today);
    gridViewSale = (MyGridView) v.findViewById(R.id.GridView_fhome_sale);
    gridViewNew = (MyGridView) v.findViewById(R.id.GridView_fhome_new);

    List<Integer> images = new ArrayList<>();
    images.add(R.drawable.adv_1);
    images.add(R.drawable.adv_2);
    images.add(R.drawable.adv_3);
    List<String> titles = new ArrayList<>();
    titles.add("地一个");
    titles.add("第二个");
    titles.add("第三个");
    Banner banner = (Banner) v.findViewById(R.id.homeBanner);
    //设置banner样式
    banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR);
    //设置图片加载器
    banner.setImageLoader(new GlideImageLoader());
    //设置图片集合
    banner.setImages(images);
    //设置banner动画效果
    banner.setBannerAnimation(Transformer.Accordion);
    //设置自动轮播,默认为true
    banner.isAutoPlay(true);
    //设置轮播时间
    banner.setDelayTime(1100);
    //设置指示器位置(当banner模式中有指示器时)
    banner.setIndicatorGravity(BannerConfig.CENTER);
    //banner设置方法全部调用完毕时最后调用
    banner.start();

    initMenuList();
    todayList = new ArrayList<>();
    saleList = new ArrayList<>();
    newList = new ArrayList<>();
    MyAdapter myAdapter = new MyAdapter(this.getContext(),menuList);
    myAdapterForToday = new MyAdapterForGoods(this.getContext(),todayList);
    myAdapterForSale = new MyAdapterForGoods(this.getContext(),saleList);
    myAdapterForNew = new MyAdapterForGoods(this.getContext(),newList);
    gridView.setAdapter(myAdapter);
    gridViewToday.setAdapter(myAdapterForToday);
    gridViewSale.setAdapter(myAdapterForSale);
    gridViewNew.setAdapter(myAdapterForNew);
    ac = new LoginAC();
    return v;
}
 
Example 4
Source File: WelcomeActivity.java    From HomeApplianceMall with MIT License 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Window win = getWindow();//返回当前Activity的Window对象,Window类中概括了Android窗口的基本属性和基本功能
    //隐藏状态栏
    win.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    requestWindowFeature(Window.FEATURE_NO_TITLE);//隐藏标题栏
    setContentView(R.layout.activity_welcome);
    images = new ArrayList<>();
    images.add(R.drawable.welcome_1);
    images.add(R.drawable.welcome_2);
    images.add(R.drawable.welcome_3);
    images.add(R.drawable.welcome_4);
    images.add(R.drawable.welcome_5);
    final Banner banner = (Banner) findViewById(R.id.welcomBanner);
    //设置banner样式
    banner.setBannerStyle(BannerConfig.NUM_INDICATOR);
    //设置图片加载器
    banner.setImageLoader(new GlideImageLoader());
    //设置图片集合
    banner.setImages(images);
    //设置banner动画效果
    banner.setBannerAnimation(Transformer.Default);
    //设置自动轮播,默认为true
    banner.isAutoPlay(false);
    //设置指示器位置(当banner模式中有指示器时)
    banner.setIndicatorGravity(BannerConfig.RIGHT);
    //banner设置方法全部调用完毕时最后调用
    banner.start();
    banner.setOnBannerListener(new OnBannerListener() {
        @Override
        public void OnBannerClick(int position) {
            if(images.size()-1 == position){
                Intent intent = new Intent(WelcomeActivity.this,MainActivity.class);
                startActivity(intent);
                finish();
            }
        }
    });
}