[安卓]新闻客户端(一)Splash
来源:互联网 发布:ember.js入门教程 编辑:程序博客网 时间:2024/05/16 17:01
这里主要是一个图片实现的动画,并且需要有一个SharedPreferences,并抽成一个工具,来判断是否第一次进入,第一次进入先进入引导页再进入主页
布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/rl_splash_all" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@drawable/splash_bg_newyear"> <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/splash_horse_newyear"> </ImageView></RelativeLayout>
需要一个监听器,到了最后一个画面,则需要准备跳转
private void setAnimation() {//第三步 动画效果合集,需要同时生效,但是有彼此不同的时间插值,需要置为falseAnimationSet set = new AnimationSet(false);//第四步(1) 旋转RotateAnimation rotate = new RotateAnimation(0, 360,Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f);//相对于自己,两个坐标轴的中点,也就是以图片中心点旋转rotate.setDuration(3000);// 时间rotate.setFillAfter(true);// 留在最后一个帧画面//第四步(2) 缩放ScaleAnimation scale = new ScaleAnimation(0, 1, 0, 1,Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f);scale.setDuration(3000); scale.setFillAfter(true);//第四步(3) 渐变AlphaAnimation alpha = new AlphaAnimation(0, 1);alpha.setDuration(3000);alpha.setFillAfter(true);//第五步(1) 将效果增加到集合里set.addAnimation(rotate);set.addAnimation(scale);set.addAnimation(alpha);// 第六步 设置动画监听set.setAnimationListener(new AnimationListener() {@Overridepublic void onAnimationStart(Animation animation) {// TODO Auto-generated method stub}@Overridepublic void onAnimationRepeat(Animation animation) {// TODO Auto-generated method stub}@Overridepublic void onAnimationEnd(Animation animation) {// TODO Auto-generated method stubjumpNextPage();}});//第五步(2) 在整个布局上启动所有动画效果rl_splash_all.startAnimation(set);}
工具
public class PrefUtils {public static final String PREF_NAME = "config";public static boolean getBoolean(Context ctx, String key,boolean defaultValue) {SharedPreferences sp = ctx.getSharedPreferences(PREF_NAME,Context.MODE_PRIVATE);return sp.getBoolean(key, defaultValue);}public static void setBoolean(Context ctx, String key, boolean value) {SharedPreferences sp = ctx.getSharedPreferences(PREF_NAME,Context.MODE_PRIVATE);sp.edit().putBoolean(key, value).commit();}}
判断
//第七部 跳转private void jumpNextPage() {//判断之前有没有显示过新手引导boolean userGuide = PrefUtils.getBoolean(this, "is_user_guide_showed",false);if (!userGuide) {// 跳转到新手引导页startActivity(new Intent(SplashActivity.this,GuideActivity.class));} else { startActivity(new Intent(SplashActivity.this,MainActivity.class));}finish();}
0 0
- [安卓]新闻客户端(一)Splash
- 安卓新闻客户端
- 安卓新闻客户端实战(一):项目简介
- [安卓]手机管家(一)splash
- 如何开发安卓新闻客户端?
- 安卓新闻客户端笔记积累
- [安卓]新闻客户端(二)引导页
- [安卓]新闻客户端(七) 一些bug~
- 安卓新闻客户端的简单实现
- 安卓开发之简易新闻客户端
- [安卓]新闻客户端(八) 新闻详情 & 编码 & 推送 & 适配
- 安卓新闻客户端编写(一) JSOUP抓取网页信息
- 仿网易安卓客户端新闻订阅页面
- 安卓新闻客户端(四)ViewPager使用
- 安卓新闻客户端(五) ListView下拉刷新 XlistView解析
- 安卓新闻客户端(三) 自定义ViewPagerIndicator tab指示符
- 安卓基础笔记5之新闻客户端--OKHttp查询
- 安卓之旅第十一站--简易新闻客户端
- SPOJ QTREE2 lct
- 为什么C++编译器不能支持对模板的分离式编译
- shell学习三十八天----执行顺序和eval
- WMI和ManagementObjectSearcher一些使用
- MySQL优化之——触发器
- [安卓]新闻客户端(一)Splash
- 使用Filter防止浏览器缓存页面或请求结果
- 类模板
- 字符串最短距离问题
- [安卓]新闻客户端(二)引导页
- LRU Cache的C++实现
- Vim 练级
- 安卓获取来去电号码
- (七十)Xcode5及以上对于状态栏和导航栏样式的设定方法