android 动画闪屏问题,Android中闪屏实现方法小结(普通闪屏、倒计时闪屏、倒计时+动画...
一、项目目录结构
二、activity_main.xml代码
xmlns:tools="http://www.easck.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.zgs.SplashScreenByXml.MainActivity" >
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="主页面" />
三、activity_splashscreen.xml代码
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/splash"
android:orientation="vertical"
android:id="@+id/ll_splashActivity">
android:id="@+id/tv_countDown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginEnd="20dp"
android:layout_marginTop="20dp"
android:textColor="@android:color/white"
android:textSize="20sp" />
四、SplashScreenActiviy.java代码
package com.zgs.SplashScreenByXml;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.TranslateAnimation;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.zgs.CommonlySplashScreen.R;
public class SplashScreenActiviy extends Activity {
private TextView tv_countDown;
private LinearLayout ll_splashActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 通过下面两行代码也可实现全屏无标题栏显示activity
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
// this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_splashscreen);
tv_countDown = (TextView) findViewById(R.id.tv_countDown);
ll_splashActivity = (LinearLayout) findViewById(R.id.ll_splashActivity);
/********************************************************************************
*
* 普通闪屏实现方式
*
* ******************************************************************************/
/*new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
finish();
}
}, 1000*4);*/
/********************************************************************************
*
* 倒计时闪屏实现方式
*
* ******************************************************************************/
/*MyCountDownTimer mc = new MyCountDownTimer(4000, 1000);
mc.start();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
finish();
}
}, 1000*4);*/
/********************************************************************************
*
* 倒计时+动画闪屏实现方式
*
* ******************************************************************************/
MyCountDownTimer mc = new MyCountDownTimer(4000, 1000);
mc.start();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
//左移动画
TranslateAnimation ta = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, -1, Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0);
ta.setDuration(2000); //设置动画执行的时间
ta.setFillAfter(true);//当动画结束后 动画停留在结束位置,然后等启动主界面后将其销毁
ll_splashActivity.startAnimation(ta);
ta.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation arg0) {
}
@Override
public void onAnimationRepeat(Animation arg0) {
}
@Override
public void onAnimationEnd(Animation arg0) {
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
finish();
}
});
}
}, 1000*4);
}
class MyCountDownTimer extends CountDownTimer {
//millisInFuture:倒计时的总数,单位毫秒
//例如 millisInFuture=1000;表示1秒
//countDownInterval:表示间隔多少毫秒,调用一次onTick方法()
//例如: countDownInterval =1000;表示每1000毫秒调用一次onTick()
public MyCountDownTimer(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
public void onFinish() {
tv_countDown.setText("开始跳转……");
}
public void onTick(long millisUntilFinished) {
tv_countDown.setText("倒计时(" + millisUntilFinished / 1000 + ")");
}
}
}
android 动画闪屏问题,Android中闪屏实现方法小结(普通闪屏、倒计时闪屏、倒计时+动画...相关推荐
- Go语言中字符串的查找方法小结
这篇文章主要介绍了Go语言中字符串的查找方法小结,示例的main函数都是导入strings包然后使用其中的方法,需要的朋友可以参考下 1.func Contains(s, substr string) ...
- kodi remote android,使用Android和iOS在Win10系统中设置Kodi Remote方法
Kodi是一个流行的流媒体应用程序,兼容windows操作系统和大多数其他设备,如Android,iOS,Linux等.Kodi是家庭娱乐的理想选择,基本上设计用于大屏幕.如果要在windows桌面上 ...
- jQuery操作iframe中js函数的方法小结
1.jquery操作iframe中的元素(2种方式) ? 1 2 var tha = $(window.frames["core_content"].document).find( ...
- ubuntu编写python脚本_python在ubuntu中的几种方法(小结)
通过ubuntu官方的apt工具包安装 通过PPA(Personal Package Archive) 的apt工具包安装 通过编译python源代码安装 通过ubuntu官方的apt工具包安装 安装 ...
- golang中字符串的查找方法小结
1)func Contains(s, substr string) bool这个函数是查找某个字符是否在这个字符串中存在,存在返回true 示例如下: import ("fmt"& ...
- java this 代替_关于JAVA中this的使用方法小结
/** * @author fengzhi-neusoft * * 本示例为了说明this的三种用法! */ package test; public class ThisTest { private ...
- jq获取id的名称_jquery中获取id值方法小结
$(document).ready(function(){ name = $('div').eq(0).attr('id'); alert(name) }); eq(0)是取第一个jq元素... eq ...
- android求助:关于播放器中的“播放/暂停”键: 用ImageButton来设置点击效果时的问题...
============问题描述============ 大家好,我最近遇到个问题: 大家都知道,播放器中的播放/暂停键是这样的逻辑:当用户点击了这个键,如果当前显示的是"播放&quo ...
- android ios滑动解锁效果,Android 高仿 IOS7 IPhone 解锁 Slide To Unlock 附源码
0. 源码下载 1. IPhone 解锁 效果图: 在最新的IOS7中,苹果更改了解锁方式,整个屏幕向右滑动都可以解锁,不再局限在一个小的矩形中.这种文字加亮移动的效果还是继承了下来.之前滑动最左边的 ...
- android中文首字母排序,Android上汉字按拼音排序如何实现?
具体的代码在 packages\providers\contactsprovider\src\com\android\providers\contacts\ContactL ocaleUtils.ja ...
最新文章
- C++自定义非极大值抑制(Canny边缘检测,亚像素方法)
- 739. Daily Temperatures - LeetCode
- css-bootstrap的安装与使用
- linux快速删除60万文件,Linux下快速删除大量文件
- D3 selectselectAll
- 宾馆管理系统java外文文献_javaEE酒店管理系统论文+任务书+设计源码+答辩PPT
- 华为悦盒EC6018V9E线刷linux教程
- CAN学习笔记二:OSEK NM 学习
- TIBCO Spotfire使用技巧:如何使Spotfire表或散点图中呈现链接中图片
- AutoCAD二次开发——引线标注
- 360免费wifi设置位置服务器,win10系统使用360免费wifi的操作方法
- js中的getDate() getMonth() getFullYear()方法;js如何获取当前日期/年月日
- 关于神经网络中的shape问题
- JavaEE企业级实战项目 智牛股第五天 Netty的使用和项目数据库搭建
- 网站微信扫码授权登录
- Linux下破解神器(thc org hc-hydra
- 气动四自由度机械手结构设计(设计说明书+CAD图纸) 套类零件自动上下料机构
- 报告称国内超八成城市房价跌回一年前 北京上海回涨
- 《推荐系统实践》- 项亮
- 埋头工作就能触及 “ 宇宙真理 ”
热门文章
- u盘安装centos8黑屏_求助啊为何装centos7一点安装就黑屏
- CS5216 Capstone DP to hdmi 1080p转换器或者转接线设计原理|CS5216 DP转HDMI转换电路原理图
- 详解3D结构光如何标定
- JavaScript:实现PigeonHoleSort鸽巢排序算法(附完整源码)
- [ C语言版 ] 数独计算器 [ 搜索剪枝法 ]
- 来 不 及 认 真 的 年 轻
- “企鹅号+时尚集团MCN”强强联手 打造19春夏时装周报道新模式
- 数据库-内外连接及左右连接的区别
- LeetCode——5785. 合并若干三元组以形成目标三元组(Merge Triplets to Form Target Triplet)[中等]——分析及代码(Java)
- s3c2440存储控制器详解