android闪屏界面

在此简单记录一下,工作中用的的一些东西

1.思路很简单

xml布局,很简单就一张默认的全局图片
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.mama.wemex3.ui.activity.SplashActivity">

    <ImageView
        android:id="@+id/iv_splash"
        android:src="@mipmap/ic_launcher"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</RelativeLayout>

2.build.gradle引入  

compile 'com.github.bumptech.glide:glide:3.7.0'
3.SplashActivity  注意:里面用了最近比较火的Glide加载本地或者网络图片(crossFade是淡入淡出属性),加载之后通过thread开启线程设置3s后进入引导页面或者主页面
public class SplashActivity extends AppCompatActivity {

    private ImageView iv_splash;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

//        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);//全屏样式
        iv_splash = (ImageView) findViewById(R.id.iv_splash);
        //获取网络图片
        Glide.with(this).load("http://pic41.nipic.com/20140507/18602184_142854861000_2.jpg").crossFade(3000).into(iv_splash);
        //3s后关闭闪屏页面
        new Thread(){
            @Override
            public void run() {
                super.run();
                try {
                    Thread.sleep(3000);
                    Intent intent = new Intent(SplashActivity.this,GuideActivity.class);
                    startActivity(intent);
                    finish();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }
        }.start();

    }
}


感觉是不是很简单,



小提示:
全屏显示也可以在AndroidManifest.xml 文件中配置  
<activity android:name=".SplashActivity"
                  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

Theme.AppCompat无全屏主题解决办法 (自己定义)

<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
</style>







<activity
            android:name=".ui.activity.SplashActivity"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>


如果用到倒计时 可以用 CountDownTimer实现

虽然不好看,来张效果图

 
 



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值