Android · 广告走灯
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 · 广告走灯的更多相关文章
- Android灯光系统--通知灯深入分析【转】
本文转自:https://www.cnblogs.com/lkq1220/p/6406261.html Android灯光系统--通知灯深入分析 通知的类别 声音 振动 闪灯 APP如何发出通知灯请求 ...
- Android灯光系统--通知灯深入分析
Android灯光系统--通知灯深入分析 通知的类别 声音 振动 闪灯 APP如何发出通知灯请求 getSystemService(获得通知服务) 构造notification 类别 其他参数(颜色, ...
- Unity加入Android广告小结
在Unity游戏加入广告大致有以下几种方式: 导入Android Jar包 导出游戏为Android项目(在Build时选中Google Android Project,这种方法可以参考将Unity3 ...
- android广告平台介绍
广告模式: 广告条:最普遍的广告模式,嵌入在应用界面内,用户点击行为会带来收入. 积分墙:应用通过限制功能.去广告等引导用户进入积分墙页面下载广告应用得到积分来换取使用的模式,用户安装完推荐广 ...
- Android灯光系统通知灯【转】
本文转载自:https://blog.csdn.net/danwuxie/article/details/82193880 一.通知灯应用程序的编写 1.首先实现一个按钮功能 <LinearLa ...
- Android广告页循环播放
摘要:项目要求做一个广告页,实现几秒更换一次广告页,下方还有指示第几张广告页,同样也支持手动左滑或右滑. 1.准备好粘贴5个有关广告页的类. ①BaseViewPager==>自定义高度的Vie ...
- Android广告轮播图实现
先看效果 第一步,布局 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmln ...
- 013 Android 实现流水灯功能+自定义控件的样式(可以复用)
1.介绍 (1)获取屏幕的焦点 android:focusable与android:focusableInTouchMode(获取屏幕焦点) 前者针对在键盘下操作的情况,如果设置为true,则键盘上下 ...
- android 广告平台 keymob
访问地址: http://www.keymob.com/
随机推荐
- POJ 1149 PIGS(Dinic最大流)
PIGS Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 20738 Accepted: 9481 Description ...
- BZOJ2916 [Poi1997]Monochromatic Triangles 数论
答案等于总三角形数-不合法数 一个不合法三角形一定存在两个顶点,在这个三角形中这个顶点的角的两边不同色 #include<cstring> #include<cmath> #i ...
- 添加一种emit的应用,反射发出,较直接调用稍慢,但好过反射与表达式树。
System.Reflection.MethodInfo mInfo = typeof(TypeParse).GetMethod("Add", System.Reflection. ...
- sql查询字段值只为汉字(桃)
SELECT * FROM roster WHERE roster.`name` >'zzzzzzzzzz' //查询roster表中name值为中文的 SELECT * FROM rost ...
- [LeetCode] Same Tree 深度搜索
Given two binary trees, write a function to check if they are equal or not. Two binary trees are con ...
- C++ 求幂的运算符是什么?
1.VB里面求幂的运算符是“^” 2.C++没有求幂的运算符, c++头文件加 #include<math.h>使用pow(x,y),可算出x的y次幂 3.C++中 “^”是按位“异或”运 ...
- Linux firmware 加载【转】
转自:http://blog.chinaunix.net/uid-22028680-id-3157922.html 1.request_firmware在内核使用,需要文件系统支持,就是说,启动的时候 ...
- C#反射(Reflection)详解
1. 什么是反射2. 命名空间与装配件的关系3. 运行期得到类型信息有什么用4. 如何使用反射获取类型5. 如何根据类型来动态创建对象6. 如何获取方法以及动态调用方法7. 动态创建委托 1.什么是反 ...
- Eigen--简单的C++矩阵计算库
晚上突然想写一段小C++程序,要用到矩阵求逆呀乘法呀之类的,所以找了一下有什么现成的可用的C++矩阵计算相关的库,发现有一大堆,在其中各种各样的配置,感觉比较麻烦.从方便性来说Eigen是最方便的了, ...
- hdu 1385(Floyed+打印路径好题)
Minimum Transport Cost Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/O ...