layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rl"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" > <ImageView
android:id="@+id/imageView"
android:layout_width="fill_parent"
android:layout_height="120dp"
android:background="@drawable/icon" /> <ImageView
android:id="@+id/imageView2"
android:layout_width="fill_parent"
android:layout_height="120dp"
android:background="@drawable/expriment" /> </RelativeLayout>

MainActivity

package com.manhua.imagead;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView; public class MainActivity extends Activity { public ImageView imageView;
public ImageView imageView2; public Animation animation1;
public Animation animation2; public boolean juage = true; public int images[] = new int[] { R.drawable.icon, R.drawable.expriment,
R.drawable.changer, R.drawable.dataline, R.drawable.preffitication }; public int count = 0; public Handler handler = new Handler(); public Runnable runnable = new Runnable() { @Override
public void run() {
// TODO Auto-generated method stub
AnimationSet animationSet1 = new AnimationSet(true);
AnimationSet animationSet2 = new AnimationSet(true);
imageView2.setVisibility(0);
TranslateAnimation ta = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF,
-1f, Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, 0f);
ta.setDuration(2000);
animationSet1.addAnimation(ta);
animationSet1.setFillAfter(true);
ta = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1.0f,
Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF,
0f, Animation.RELATIVE_TO_SELF, 0f);
ta.setDuration(2000);
animationSet2.addAnimation(ta);
animationSet2.setFillAfter(true); imageView.startAnimation(animationSet1);
imageView2.startAnimation(animationSet2);
imageView.setBackgroundResource(images[count % images.length]);
count++;
imageView2.setBackgroundResource(images[count % images.length]); if (juage)
handler.postDelayed(runnable, 6000);
Log.i("handler", "handler");
} };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); imageView = (ImageView) findViewById(R.id.imageView);
imageView2 = (ImageView) findViewById(R.id.imageView2); imageView2.setVisibility(4);
handler.postDelayed(runnable, 2000);
} public void onPause() {
juage = false;
super.onPause();
} }

Android · 广告走灯的更多相关文章

  1. Android灯光系统--通知灯深入分析【转】

    本文转自:https://www.cnblogs.com/lkq1220/p/6406261.html Android灯光系统--通知灯深入分析 通知的类别 声音 振动 闪灯 APP如何发出通知灯请求 ...

  2. Android灯光系统--通知灯深入分析

    Android灯光系统--通知灯深入分析 通知的类别 声音 振动 闪灯 APP如何发出通知灯请求 getSystemService(获得通知服务) 构造notification 类别 其他参数(颜色, ...

  3. Unity加入Android广告小结

    在Unity游戏加入广告大致有以下几种方式: 导入Android Jar包 导出游戏为Android项目(在Build时选中Google Android Project,这种方法可以参考将Unity3 ...

  4. android广告平台介绍

    广告模式:   广告条:最普遍的广告模式,嵌入在应用界面内,用户点击行为会带来收入.   积分墙:应用通过限制功能.去广告等引导用户进入积分墙页面下载广告应用得到积分来换取使用的模式,用户安装完推荐广 ...

  5. Android灯光系统通知灯【转】

    本文转载自:https://blog.csdn.net/danwuxie/article/details/82193880 一.通知灯应用程序的编写 1.首先实现一个按钮功能 <LinearLa ...

  6. Android广告页循环播放

    摘要:项目要求做一个广告页,实现几秒更换一次广告页,下方还有指示第几张广告页,同样也支持手动左滑或右滑. 1.准备好粘贴5个有关广告页的类. ①BaseViewPager==>自定义高度的Vie ...

  7. Android广告轮播图实现

    先看效果 第一步,布局 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmln ...

  8. 013 Android 实现流水灯功能+自定义控件的样式(可以复用)

    1.介绍 (1)获取屏幕的焦点 android:focusable与android:focusableInTouchMode(获取屏幕焦点) 前者针对在键盘下操作的情况,如果设置为true,则键盘上下 ...

  9. android 广告平台 keymob

    访问地址: http://www.keymob.com/

随机推荐

  1. [bzoj3944] sum [杜教筛模板]

    题面: 传送门 就是让你求$ \varphi\left(i\right) $以及$ \mu\left(i\right) $的前缀和 思路: 就是杜教筛的模板 我们把套路公式拿出来: $ g\left( ...

  2. vuemock数据

    http://www.jianshu.com/p/ccd53488a61b dev.server.js 61 行 app.use('/mock',express.static('./mock'))

  3. C语言中 单引号与双引号的区别

    在C语言中,字符用单引号,字符串用双引号.在c1='a';中,'a'是字符常量,必须用单引号."a"表示字符串,包含两个字符,一个是'a',一个是'\0'. 用数组来存储字符串. ...

  4. Window下安装使用RabbitMQ

    RabbitMQ官网 http://www.rabbitmq.com 下载地址 http://www.rabbitmq.com/download.html 一 Windows下安装RabbitMq 1 ...

  5. 挑战程序设计竞赛》P345 观看计划

                                                 <挑战程序设计竞赛>P345 观看计划 题意:一周一共有M个单位的时间.一共有N部动画在每周si时 ...

  6. 【HDOJ5521】Meeting(最短路)

    题意:有n个点,m个点集,每个点集中有e[i]个点,同一点集的点互相之间到达需要t[i]单位的时间,求min(max(dis(1,i),dis(i,n))),i属于[1,n] 输出最小值并増序输出所有 ...

  7. FckEditor2.65使用范例源码

    原文发布时间为:2009-10-12 -- 来源于本人的百度文章 [由搬家工具导入] 下载地址:http://www.xmaspx.com/Services/FileAttachment.ashx?A ...

  8. 【HugeChm】HugeChm制作chm帮助文档

    1.下载软件:HugeChm.exe 2.开始打包:  3.选择开始打包即可

  9. LeetCode OJ-- Generate Parentheses *

    https://oj.leetcode.com/problems/generate-parentheses/ 输入n产生n个( ,n个 )组成的所有合法的括号组合. 现在纸上画画,找到规律: 1.每一 ...

  10. LeetCode OJ-- Container With Most Water

    https://oj.leetcode.com/problems/container-with-most-water/ 不同高度的柱子排一列,两个柱子可以组成一个容器,求最大容积. 最直观的方法就是暴 ...