程序实现渐变
来源:互联网 发布:php 魔术方法 编辑:程序博客网 时间:2024/06/05 09:08
准备一张名为picture的图片。
在main.xml中:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
android:orientation="vertical"
android:gravity="center_horizontal">
<ImageView
android:id="@+id/mlyw"
android:layout_marginTop="8dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/picture"/>
<Button
android:id="@+id/but"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_marginTop="20dp"
android:background="#3399ff"
android:textColor="#ffffff"
android:text="开始渐变"/>
</LinearLayout>
在MyAnimationDemo.java中:
package com.li.animation;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AlphaAnimation;
import android.view.animation.AnimationSet;
import android.widget.Button;
import android.widget.ImageView;
import android.support.v4.app.NavUtils;
public class MyAnimationDemo extends Activity {
private ImageView mlyw = null;
private Button but = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setContentView(R.layout.main);
this.mlyw = (ImageView)super.findViewById(R.id.mlyw);
this.but = (Button)super.findViewById(R.id.but);
this.but.setOnClickListener(new OnClickListenerImpl());
}
private class OnClickListenerImpl implements OnClickListener{
public void onClick(View v) {
AnimationSet set = new AnimationSet(true);
AlphaAnimation alpha = new AlphaAnimation(1,0); //完全显示-->透明
alpha.setDuration(6000); //6秒完成
set.addAnimation(alpha); //增加动画
MyAnimationDemo.this.mlyw.startAnimation(set); //启动动画
}
}
}
- 程序实现渐变
- 小程序实现渐变动画
- ios 实现颜色渐变(渐变色)
- 实现透明度渐变和颜色渐变
- 用css实现渐变
- CSS实现网页背景渐变
- 实现 颜色渐变
- 实现背景渐变功能
- JQuery实现背景图片渐变!
- css实现网页背景渐变
- css实现渐变效果
- 实现屏幕色彩渐变
- CSS 实现色彩渐变
- IOS_CAGradientLayer 实现渐变色
- 配置文件实现渐变
- svgdom实现线性渐变
- iOS 实现渐变色
- 实现渐变色
- mysql没有解决的几个问题
- Hibernate的N+1问题
- 【zz】浅谈MySQL存储引擎选择 InnoDB还是MyISAM
- 《精通HTML5编程》第四章:地理位置API
- 安卓开发-内存使用分析
- 程序实现渐变
- 读你妹上传问题
- linux中文件打包、压缩和解压
- C++复制构造函数与赋值操作符
- Hibernate学习
- Word Reversal
- There is no getter for property named 'xxxx' in 'class java.lang.Integer
- 冒泡算法排序数组
- 树的递归遍历和非递归遍历(前序和后序)