以GIF为背景加载图片实现动态倒计时
来源:互联网 发布:js href 跳转 编辑:程序博客网 时间:2024/04/29 18:42
/**
*main主方法
*/
package com.example.timer2;
import com.bumptech.glide.Glide;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
public class MainActivity extends Activity {
private int recLen = 6;
private TextView txtView;
private ImageView ivNumber;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
setContentView(R.layout.activity_main);
// txtView = (TextView) findViewById(R.id.txtTime);
ImageView ivBackground = (ImageView) findViewById(R.id.ivBackground);
ivNumber = (ImageView) findViewById(R.id.ivNumber);
Glide.with(MainActivity.this).load(R.drawable.a).into(ivBackground);
handler.postDelayed(runnable, 1000);
}
Handler handler = new Handler();
Runnable runnable = new Runnable() {
@Override
public void run() {
if (recLen < 2) {
return;
}
recLen--;
//设置图片
switch (recLen) {
case 5:
Glide.with(MainActivity.this).load(R.mipmap.five).into(ivNumber);
break;
case 4:
Glide.with(MainActivity.this).load(R.mipmap.four).into(ivNumber);
break;
case 3:
Glide.with(MainActivity.this).load(R.mipmap.three).into(ivNumber);
break;
case 2:
Glide.with(MainActivity.this).load(R.mipmap.two).into(ivNumber);
break;
case 1:
Glide.with(MainActivity.this).load(R.mipmap.one).into(ivNumber);
break;
}
//txtView.setText("" + recLen);
handler.postDelayed(this, 1000);
}
};
}
/**
*XML布局两个framelayout
*/
<LinearLayout 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="#212021"
android:orientation="vertical"
tools:context="${relativePackage}.${activityClass}" >
<FrameLayout
android:id="@+id/fl_tip"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true" >
<ImageView
android:id="@+id/ivBackground"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:background="@android:color/transparent" >
<TextView
android:id="@+id/txBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10px"
android:text="张三"
android:textColor="#ffffff"
android:textSize="20px" />
<ImageView
android:id="@+id/ivNumber"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginBottom="62dp"
android:layout_marginLeft="113dp"
android:layout_marginTop="150px" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="10px"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/txReady"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="倒计时即将开始"
android:textColor="#ffffff"
android:textSize="24px" />
<TextView
android:id="@+id/txKilo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4px"
android:text="开始"
android:textColor="#ffffff"
android:textSize="18px" />
</LinearLayout>
</FrameLayout>
</FrameLayout>
</LinearLayout> 0 0
- 以GIF为背景加载图片实现动态倒计时
- iOS加载GIF动态图片
- UIImageView加载动态gif图片
- Qt 使用QMovie加载gif图片实现动态等待窗口
- 使用CSS3实现动态加载gif图片的效果
- Photoshop实现修改gif格式动态图片,如切换背景颜色等.....
- VC中加载GIF格式动态图片
- MFC 加载gif动态图片的方法
- MFC加载gif动态图片的方法
- vc6.0中用GDIPlus实现加载动态gif图片(非MFC实现)
- 以图片为背景 的登陆界面
- PS做以图片为文字背景
- C/C++实现显示GIF动态图片
- 用PS将gif动态图片导出为多张单帧图片
- VC中加载GIF格式动态图片的详细方法!
- VC中加载GIF格式动态图片的详细方法!
- VC中加载GIF格式动态图片的详细方法!
- VC的MFC工程加载GIF格式动态图片
- Run-Time Check Failure #2 - Stack around the variable 'chCommand' was corrupted.
- 我在网吧撸啊撸
- Linux基础学习(一)
- Session啊Session
- PHPExcel
- 以GIF为背景加载图片实现动态倒计时
- EDIUS设置字幕时注意事项
- cocos2d - JS 重力感应监听
- 关于getline的几点
- 文章索引~软件设计
- 获取table第一列的值,并进行字符串处理
- Java 解惑:Comparable 和 Comparator 的区别
- EasyUI
- Android 获取不到控件位置信息的解决办法