倒计时欢迎界面(更有条理)
来源:互联网 发布:都市校园网络高手小说 编辑:程序博客网 时间:2024/06/09 23:39
广告倒计时欢迎界面的实现,倒计时欢迎界面
今天更新了一个App,打开这个App后弹出的页面是一个广告倒计时的页面,倒计时完毕后进入主界面。于是我闲着没事儿简易实现了一下这个功能,如图:
实现这个效果也很容易,在相应布局问下中添加TextView控件,控件的值就是倒计时的数字,这里我给倒计时添加了一个动画效果,项目的目录结构如下:
AndroidManifest.xml
这里我配置了WelcomeActivity界面作为广告界面,配置它为应用的第一个activity,并且隐藏其标题。
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.timewelcome" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" > </activity> <activity android:name=".WelcomeActivity" android:label="@string/title_activity_welcome" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application></manifest>
WelcomeActivity.java
package com.example.timewelcome;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.os.Handler;import android.view.Window;import android.view.animation.Animation;import android.view.animation.AnimationUtils;import android.widget.TextView;public class WelcomeActivity extends Activity { // 声明控件对象 private TextView textView; private int count = 5; private Animation animation; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 去除标题 requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_welcome); // 初始化控件对象 textView = (TextView) findViewById(R.id.textView); animation = AnimationUtils.loadAnimation(this, R.anim.animation_text); //textView.startAnimation(animation); handler.sendEmptyMessageDelayed(0, 1000); } private int getCount() { count--; if (count == 0) { Intent intent = new Intent(this, MainActivity.class); startActivity(intent); finish(); } return count; } private Handler handler = new Handler() { public void handleMessage(android.os.Message msg) { if (msg.what == 0) { textView.setText(getCount()+""); handler.sendEmptyMessageDelayed(0, 1000); animation.reset(); textView.startAnimation(animation); } }; };}
activity_welcome.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/image" tools:context="${relativePackage}.${activityClass}" > <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:orientation="horizontal" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:text="广告倒计时:" android:textColor="#ffffff" android:textSize="20sp" /> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:text="5" android:textColor="#ffffff" android:textSize="20sp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:text="秒" android:textColor="#ffffff" android:textSize="20sp" /> </LinearLayout></FrameLayout>
动画的xml文件animation_text.xml存放在了res/anim目录下,实现透明度和缩放的动画。
animation_text.xml
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" > <alpha android:duration="1000" android:fromAlpha="0.0" android:toAlpha="1.0" /> <scale android:duration="800" android:fromXScale="1.5" android:fromYScale="1.5" android:pivotX="50%" android:pivotY="50%" android:toXScale="1.0" android:toYScale="1.0" /></set>
阅读全文
0 0
- 倒计时欢迎界面(更有条理)
- Android学习之路-----倒计时欢迎界面(更有条理)
- 欢迎界面倒计时
- 广告倒计时欢迎界面的实现,倒计时欢迎界面
- 广告倒计时欢迎界面的实现
- 欢迎界面跳转到程序主界面之倒计时,线程
- 类加载机制详解(有条理)
- swift中cell的两种创建区别和extension的使用。让我们开发更有条理
- 使用asp.net mvc里面的area让网站更有条理
- 6.倒计时界面
- 欢迎界面
- 欢迎界面
- 欢迎界面
- 欢迎界面
- 欢迎界面
- 欢迎界面
- 欢迎界面
- 如何让思想(自己的,别人的)更有条理:与这个话题有关的几本书 (第二版)蓝色字体的是第二版新增或修改的
- 数据库拆分:横向拆分和纵向拆分
- MyEclipse 启动报错:'Building workspace' has encountered a problem解决方法
- 监督学习与无监督学习
- C++ auto自动类型
- RabbitMQ任务分发
- 倒计时欢迎界面(更有条理)
- 全卷积网络 FCN 详解
- 事物、数据锁
- 让尸体说话-法医密档
- mysql的一大坑——细说mysql 开启log_bin日志以用于恢复数据库
- wireshark二三事
- vue.js 2.0的一些变化(一、基本API)
- QML之QQmlApplicationEngine
- 【素数打表】 【模板】