可能是Android最简单的欢迎页面实现
来源:互联网 发布:国内做云计算的公司 编辑:程序博客网 时间:2024/05/08 11:32
- 例如QQ的经典欢迎页面
前言
目前市面上的大多数 App 都有一个欢迎页面,有如下优点:
1. 利用展示欢迎页面的时间来加载数据
2. 展示品牌设计风格
步骤
- 创建布局文件
- 设置欢迎页面
- 延时 2S 跳转
创建布局文件
<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayout 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.ethan.imtest.controller.activity.SplashActivity"> <ImageView android:id="@+id/splashview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:layout_marginLeft="8dp" android:layout_marginRight="8dp" android:layout_marginTop="8dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" app:srcCompat="@drawable/atguigu_logo" /></android.support.constraint.ConstraintLayout>
设置欢迎界面
<activity android:name=".controller.activity.SplashActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
延时 2s 跳转
使用 Handler 执行延时2s的操作
//延时两秒钟 private Handler handler=new Handler(){ public void handleMessage(Message msg) { //如果当前activity已经退出,不对消息进行处理 if (isFinishing()){ return; } toMainOrLogin(); } }; //选择进入主页面还是登录页面 protected void toMainOrLogin(){ new Thread(new Runnable() { @Override public void run() { //如果登陆过,进入主界面 if (EMClient.getInstance().isLoggedInBefore()){ Intent intent = new Intent(SplashActivity.this,MainActivity.class); startActivity(intent); } else { //没有登录过,进入登录界面 Intent intent=new Intent(SplashActivity.this,LoginActivity.class); startActivity(intent); } finish(); } }).start(); } @Override protected void onDestroy(){ //销毁消息 super.onDestroy(); handler.removeCallbacksAndMessages(null); }
实现效果
阅读全文
0 0
- 可能是Android最简单的欢迎页面实现
- Android SeekBar 禁止拖动和点击的实现(可能是最简单完美的实现)
- 震惊!这可能是最简单的Android路由框架
- android 简单的欢迎页面
- Android实现简单地APP欢迎页面
- 这可能是最快最简单的赚钱方法了!
- 可能是最简单的感知机算法
- 可能是安装wget最简单的方式
- Android GridView 点击效果(可能是最快捷的实现,另有福利)
- Android最简单的欢迎界面(一)
- 这可能是2017最经典的Android面试题
- Android开发学习笔记(六):最简单的办法实现APP欢迎界面
- 可能是ThinkPHP导航高亮显示当前页面的最简便的方法
- android 简单设置欢迎页面
- Android 简单欢迎页面设计
- Android这可能是当今最火,功能最全的快速开发框架了
- 可能是最鸡汤的面经
- 可能是最鸡汤的面经
- 文件上传漏洞(绕过姿势) 转载防丢失
- 简单运算工厂
- 使用CSS伪元素模拟float:center效果
- 跨域
- Hyperledger Fabric SDK 示例fabric-samples-《balance-transfer》之四《安装chaincode》
- 可能是Android最简单的欢迎页面实现
- zabbix通过snmp监控带外管理ping不可用的问题
- 3、认识目标客户:6个角度与2步阶梯
- 创建web项目
- vue2计算属性、方法、及侦听笔记
- Centos下查看占用端口并关闭进程方法
- <meta http-equiv="X-UA-Compatible" content="IE=Edge"> 博客分类: 浏览器兼容性 JavaScript 作者:zccst 1,X-UA-Co
- 第二届日知录企业存储峰会拉开帷幕
- 六大机构好评的Teradata 究竟有哪些过人之处?