package com.tainyunjuhe.news.activity; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.view.Window; import android.view.WindowManager; import android.widget.Button; import android.widget.ImageView; import com.tainyunjuhe.news.R; import com.tainyunjuhe.news.entity.GlideImageLoader; import com.youth.banner.Banner; import com.youth.banner.BannerConfig; import java.util.ArrayList; import java.util.List; public class QiDong extends AppCompatActivity { private boolean stopThread=false;//是否开启线程 private boolean ok=true;//是否跳转 private Banner banner; private List<Integer> images; private Button bt_click; private Intent mIntent; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //隐藏标题栏以及状态栏 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); /**标题是属于View的,所以窗口所有的修饰部分被隐藏后标题依然有效,需要去掉标题**/ requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_qi_dong); banner= (Banner) findViewById(R.id.banner); bt_click= (Button) findViewById(R.id.bt_click); bt_click.getBackground().setAlpha(50);设置透明度(0-200多)mIntent=new Intent(QiDong.this,MainActivity.class);bt_click.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ok=false; startActivity(mIntent); finish(); } }); private void firstShow(){ images=new ArrayList<>(); images.add(R.drawable.ic_launcher); images.add(R.drawable.ic_launcher5); images.add(R.drawable.ic_launcher2); images.add(R.drawable.ic_launcher3); images.add(R.drawable.ic_launcher4); /*//设置banner样式 banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE);*/ //设置图片加载器 banner.setImageLoader(new GlideImageLoader()); //设置图片集合 banner.setImages(images); //设置自动轮播,默认为true banner.isAutoPlay(false); //设置轮播时间 banner.setDelayTime(1500); //设置指示器位置(当banner模式中有指示器时) banner.setIndicatorGravity(BannerConfig.RIGHT); //banner设置方法全部调用完毕时最后调用 banner.start(); new Thread(){ @Override public void run() { super.run(); if (!stopThread){ try { sleep(3000); if (ok){//设置点击按钮后不再从线程跳转,否则会从线程再跳转一次 startActivity(mIntent); finish(); } } catch (InterruptedException e) { e.printStackTrace(); } } } }.start(); } @Override protected void onPause() { stopThread=true;//关闭线程 super.onPause(); }}
APP首次启动:图片轮播3秒后进入首页或点击按钮进入首页(这里用的banner轮播)
最新推荐文章于 2019-05-30 17:20:55 发布