当前位置:  编程技术>移动开发
本页文章导读:
    ▪相关oppo蝴蝶解锁的三D技术        有关oppo蝴蝶解锁的三D技术oppo手机的界面设计也是很漂亮的。在很多界面中使用了3D技术塑造出了大量华丽的效果。在蝴蝶解锁中使用了两个对称的三D变幻,宛如蝴蝶翅膀上美丽的花纹.........
    ▪ UIScrollView步骤 属性详解        UIScrollView方法 属性详解 --前言:UIScrollView使用非常广,本文研究UIScrollView各属性和方法,明白它们的意义、作用。在后面的一篇文章有整理UIScrollView一些常见用法以及一些效果的实现思路。.........
    ▪ 帧动画片       帧动画     准备8张图片名字分别为:loading1、loading2、loading3、loading4、                      Loading5、loading6、loading7、loading8。     在main.xml中:   <LinearLayout     android:id="@+id/.........

[1]相关oppo蝴蝶解锁的三D技术
    来源: 互联网  发布时间: 2014-02-18
有关oppo蝴蝶解锁的三D技术

oppo手机的界面设计也是很漂亮的。在很多界面中使用了3D技术塑造出了大量华丽的效果。在蝴蝶解锁中使用了两个对称的三D变幻,宛如蝴蝶翅膀上美丽的花纹。在受到用户点击后,随风缓慢上下扇动,充满浪漫的动感色彩。这里只在技术角度做一些探索。

P { margin-bottom: 0.21cm; }

这个效果由两个子view合成,每个各占整个屏幕的一半。左边子view以右边界为旋转中心,手指向右滑动距离转为绕Y轴施转的角度,角度为正。右边子view以左边界为旋转中心,手指向左滑动距离转为绕Y轴旋转的角度,角度为负,这样恰好与x轴方向一致。这种效果经过转为,可以转为像两扇门一样开关,也是很有意思的。为了保证两个view的对称性,我这里使用一张图片,沿中线分割为两个view的背景。P { margin-bottom: 0.21cm; }

可以使用函数Bitmap.createBitmap实现.


P { margin-bottom: 0.21cm; }

左view的背景,LeftView.java:


package com.magcomm.lockscrenn;

import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Camera;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.view.View;

class LeftView extends View {
	Bitmap leftbm = null;
	public int g_r = 0;
	private int scr_w = 0, scr_h = 0;

	public void refrashView(int gr) {
		g_r = gr;
		invalidate();
	}
	public LeftView(Context context) {
		super(context);
	}

	void setBitmap(Bitmap bm) {
		leftbm = bm;
		scr_w = bm.getWidth() * 2;
		scr_h = bm.getHeight();
	}

	@Override
	protected void onConfigurationChanged(Configuration newConfig) {
		// TODO Auto-generated method stub
		super.onConfigurationChanged(newConfig);
	}

	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		// TODO Auto-generated method stub
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);

	}

	@Override
	protected void onLayout(boolean changed, int left, int top, int right,
			int bottom) {
		// TODO Auto-generated method stub
		super.onLayout(changed, left, top, right, bottom);
	}

	@Override
	protected void onDraw(Canvas canvas) {
		// TODO Auto-generated method stub
		super.onDraw(canvas);
		float deg = (g_r * 1.0f / scr_w) * 180;
		if (deg >= 90) {
			canvas.drawBitmap(leftbm, rotateY((int) deg), null);

		} else if (deg > 0) {
			canvas.drawBitmap(leftbm, rotateY((int) deg), null);
			// lv.bringToFront();
		} else {
			canvas.drawBitmap(leftbm, rotateY((int) 0), null);
		}
	}

	private int centerX = 0, centerY = 0;
	// 转动的总距离,跟度数比例1:1
	private int deltaX = 0, deltaY = 0;
	// 图片宽度高度
	private int bWidth, bHeight;
	// 摄像机
	private Camera mCamera = new Camera();
	private Matrix mMatrix = new Matrix();

	Matrix rotateXY(int degreeX, int degreeY) {
		deltaX = degreeX;
		deltaY = degreeY;
		centerX = scr_w / 2;
		centerY = scr_h / 2;
		mCamera.save();
		mCamera.rotateY(deltaY);
		mCamera.rotateX(-deltaX);
		mCamera.translate(0, 0, 0);
		mCamera.getMatrix(mMatrix);
		mCamera.restore();
		// 以图片的中心点为旋转中心,如果不加这两句,就是以(0,0)点为旋转中心
		mMatrix.preTranslate(-centerX, -centerY);
		mMatrix.postTranslate(centerX, centerY);
		// mCamera.save();

		// postInvalidate();
		return mMatrix;
	}

	Matrix rotateY(int degreeY) {
		return rotateXY(0, degreeY);
	}

}

右View的代码RightView.java:



package com.magcomm.lockscrenn;

import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Camera;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.view.View;

class RightView extends View {
	Bitmap rightbm = null;
	public int g_r = 0;
	private int scr_w = 0, scr_h = 0;

	public void refrashView(int gr) {
		g_r = gr;
		invalidate();
	}
	public RightView(Context context) {
		super(context);
	}

	void setBitmap(Bitmap bm) {
		rightbm = bm;
		scr_w = bm.getWidth() * 2;
		scr_h = bm.getHeight();
	}

	@Override
	protected void onConfigurationChanged(Configuration newConfig) {
		// TODO Auto-generated method stub
		super.onConfigurationChanged(newConfig);
	}

	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		// TODO Auto-generated method stub
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
	}

	@Override
	protected void onLayout(boolean changed, int left, int top, int right,
			int bottom) {
		// TODO Auto-generated method stub
		super.onLayout(changed, left, top, right, bottom);
	}

	@Override
	protected void onDraw(Canvas canvas) {
		// TODO Auto-generated method stub
		super.onDraw(canvas);
		float deg = (g_r * 1.0f / scr_w) * 180;
		if (deg <= -90) {
			canvas.drawBitmap(rightbm, rotateY2((int) deg), null);
		} else if (deg < 0) {
			canvas.drawBitmap(rightbm, rotateY2((int) deg), null);
			// rv.bringToFront();

		} else {
			canvas.drawBitmap(rightbm, rotateY2(0), null);
		}
	}

	// 图片的中心点坐标
	private int centerX = 0, centerY = 0;
	// 转动的总距离,跟度数比例1:1
	private int deltaX = 0, deltaY = 0;
	// 图片宽度高度
	private int bWidth, bHeight;
	// 摄像机
	private Camera mCamera = new Camera();
	private Matrix mMatrix = new Matrix();

	Matrix rotateXY2(int degreeX, int degreeY) {
		deltaX = degreeX;
		deltaY = degreeY;
		centerX = scr_w / 2;
		centerY = scr_h / 2;
		mCamera.save();
		mCamera.rotateY(deltaY);
		mCamera.rotateX(-deltaX);
		mCamera.translate(scr_w / 2, 0, 0);
		mCamera.getMatrix(mMatrix);
		mCamera.restore();
		// 以图片的中心点为旋转中心,如果不加这两句,就是以(0,0)点为旋转中心
		mMatrix.preTranslate(-centerX, -centerY);
		mMatrix.postTranslate(centerX, centerY);
		// mCamera.save();

		// postInvalidate();
		return mMatrix;
	}

	Matrix rotateY2(int degreeY) {
		return rotateXY2(0, degreeY);
	}
}

P { margin-bottom: 0.21cm; }


下面代码是两个view的动画效果,手指放开时出现缓慢的上下的有衰减的扇动效果,宛如蝴蝶颤抖的翅膀。本来自己写了一个弹簧振子的模型,通过滑动距离转化为弹簧的能量波动,进而转化为扇动的初速度,加上弹簧的阻尼运动的衰减系数,使其做带负加速度的圆周运动。但运行效果不太满意,大概需要使用JNI来实现才能满足吧,后来采取了系统自带的动画实现。


int ani_index = 0;

	private void applyRotation(float start, float end, final View v) {
		// 计算中心点
		final float centerX = scr_w / 2.0f;
		final float centerY = scr_h / 2.0f;
		final Rotate3dAnimation rotation = new Rotate3dAnimation(start, end, 0,
				0, 0, 0, 0, 0, centerX, centerY, true);
		rotation.setDuration(500);
		// rotation.setFillAfter(true);
		rotation.setRepeatCount(1);
		rotation.setRepeatMode(Animation.REVERSE);
		// rotation.setFillAfter(true);
		// rotation.setDetachWallpaper(true);
		rotation.setInterpolator(new AnticipateInterpolator());
		// 设置监听
		rotation.setAnimationListener(new Animation.AnimationListener() {
			public void onAnimationStart(Animation animation) {
			}

			// 动画结束
			public void onAnimationEnd(Animation animation) {
				// tv.post(new SwapViews());
				startAni(ani_index++);
			}

			public void onAnimationRepeat(Animation animation) {
			}
		});
		v.startAnimation(rotation);
	}

	/**
	 * 
	 * AccelerateDecelerateInterpolator 在动画开始与介绍的地方速率改变比较慢,在中间的时候加速
	 * 
	 * AccelerateInterpolator 在动画开始的地方速率改变比较慢,然后开始加速
	 * 
	 * AnticipateInterpolator 开始的时候向后然后向前甩
	 * 
	 * AnticipateOvershootInterpolator 开始的时候向后然后向前甩一定值后返回最后的值
	 * 
	 * BounceInterpolator 动画结束的时候弹起
	 * 
	 * CycleInterpolator 动画循环播放特定的次数,速率改变沿着正弦曲线
	 * 
	 * DecelerateInterpolator 在动画开始的地方快然后慢
	 * 
	 * LinearInterpolator 以常量速率改变
	 * 
	 * OvershootInterpolator 向前甩一定值后再回到原来位置
	 * 
	 * @param start
	 * @param end
	 * @param v
	 * @param time
	 */
	private void applyRotation2(float start, float end, final View v, long time) {
		// 计算中心点
		final float centerX = scr_w / 2.0f;
		final float centerY = scr_h / 2.0f;
		final Rotate3dAnimation rotation = new Rotate3dAnimation(start, end, 0,
				0, 0, 0, 0, 0, centerX, centerY, true);
		rotation.setDuration(time);
		// rotation.setFillAfter(true);
		rotation.setRepeatCount(0);
		rotation.setRepeatMode(Animation.REVERSE);
		// rotation.setFillAfter(true);
		// rotation.setDetachWallpaper(true);
		rotation.setInterpolator(new LinearInterpolator());
		// 设置监听
		rotation.setAnimationListener(new Animation.AnimationListener() {
			public void onAnimationStart(Animation animation) {
			}

			// 动画结束
			public void onAnimationEnd(Animation animation) {
				// tv.post(new SwapViews());
				startAni(ani_index++);
			}

			public void onAnimationRepeat(Animation animation) {
			}
		});
		v.startAnimation(rotation);
	}

	void startAni(int index) {
		// final int ani_deg1[][] = {{60, 0}, {40, 0}, {20, 0}};
		// final int ani_deg1[][] = {{0, 60}, {0, 40}, {0, 20}};
		final int ani_deg1[][] = { { 0, 80 }, { 80, 0 }, { 0, 60 }, { 60, 0 },
				{ 0, 40 }, { 40, 0 } };
		// final int ani_deg2[][] = {{-60, 0}, {-40, 0}, {-20, 0}};
		final int ani_deg2[][] = { { 0, -80 }, { -80, 0 }, { 0, -60 },
				{ -60, 0 }, { 0, -40 }, { -40, 0 } };
		final int time[] = { 500, 500, 400, 400, 200, 200 };
		if (index > 5) {
			ani_index = 0;
		} else {
			if (u_x <= (scr_w / 2)) {
				applyRotation2(ani_deg1[index][0], ani_deg1[index][1], lv,
						time[index]);
			} else {
				applyRotation2(ani_deg2[index][0], ani_deg2[index][1], rv,
						time[index]);
			}
		}

	}

P { margin-bottom: 0.21cm; }

在oppo的解锁效果中,view的背面加入了对窗口buffer的特殊处理。使我们能够看到一个打开新窗口的效果,如下图:

P { margin-bottom: 0.21cm; }


P { margin-bottom: 0.21cm; }

需要添加如下函数。这里调用了系统的隐藏函数Surface.screenshot,必须使用系统签名。加入系统app中才能使用。当然,也许你也可以使用反射实现。

P { margin-bottom: 0.21cm; }

publicBitmap getScreenBuffer()

{

DisplaymDisplay;

DisplayMetricsmDisplayMetrics;

MatrixmDisplayMatrix = new Matrix();


WindowManagermWindowManager = (WindowManager) mContext

.getSystemService(Context.WINDOW_SERVICE);

mDisplay= mWindowManager.getDefaultDisplay();

mDisplayMetrics= new DisplayMetrics();

mDisplay.getRealMetrics(mDisplayMetrics);

mDisplay.getRealMetrics(mDisplayMetrics);

float[]dims = { mDisplayMetrics.widthPixels,

mDisplayMetrics.heightPixels};

mlock= Surface.screenshot((int) dims[0], (int) dims[1]);

returnmlock;

}



    
[2] UIScrollView步骤 属性详解
    来源: 互联网  发布时间: 2014-02-18
UIScrollView方法 属性详解

--前言:UIScrollView使用非常广,本文研究UIScrollView各属性和方法,明白它们的意义、作用。在后面的一篇文章有整理UIScrollView一些常见用法以及一些效果的实现思路。

--参考文章:http://www.cocoachina.com/iphonedev/sdk/2010/1224/2503.html  &&  http://zjqzy03080312.blog.163.com/blog/static/18574280720121121105928687  &&  http://blog.csdn.net/wzzvictory/article/details/9264335  
--官方查阅文档  https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIScrollView_Class/Reference/UIScrollView.html 

--介绍:UIScrollView用于在一个小范围里显示很大的内容的控件。通过用户平滑、手捏手势,在这个小区域里查看不同内容。是UITableView和UITextView的父类。它是视图,但是比较特殊,可以看成把它看成2层的结构。上面是它的frame层,跟一般试图一样,是它的可见区域,下面层是contentView,可以滑动。 

======常用属性======

--CGPoint contentOffSet:contentView的偏移值(正常contentOffSet.x/y值都为正数,但有时(bounces = YES)拽出边界了或者contentInset设置了,还是会出现负数,伴随着contentView滑动,总在改变);

--CGSize contentSize:contentView的大小;

--UIEdgeInsets contentInset:contentView四周的扩展大小,相当改变ContentView的大小,但不是改变contentSize(UIEdgeInsets是个结构体,里面的数值可能是负数,所以扩展的结果可能是contentView被蚕食了一部分。但不管contentView变大了还是变小了,contentOffSet的值还是相比原来大小的偏移);

--id<UIScrollerViewDelegate> delegate:它的代理;

--BOOL directionalLockEnabled:默认是NO,可以在垂直和水平方向同时运动。当值是YES时,假如一开始是垂直或者是水平运动,那么接下来会锁定另外一个方向的滚动。假如一开始是对角方向滚动,则不会禁止某个方向(测试锁定不了,难道是contentsize跟frame高度或宽度一样时用的)

--BOOL bounces:默认是 yes,就是滚动超过边界会反弹有反弹回来的效果。假如是 NO,那么滚动到达边界会立刻停止

--UIScrollViewIndicatorStyle  indicatorStyle:设定滚动条的样式;

--BOOL alwaysBounceVertical:默认no,控制垂直方向遇到边框是否反弹(但bounces为NO时,它为yes,也不反弹。/if YES and bounces is YES, even if content is smaller than bounds, allow drag vertically,测试不好使);

--BOOL alwaysBounceHorizontal:默认no,控制水平方向遇到边框是否反弹(但bounces为NO时,它为yes,也不反弹);

--BOOL pagingEnabled:default NO,contentView是否整页翻动;

--BOOL scrollEnabled:default YES,contentView是否能滚动;

--BOOL showsHorizontalScrollIndicator:default YES,是否显示水平方向的滚动条;

--BOOL showsVerticalScrollIndicator:default YES  是否显示垂直方向的滚动条;

--UIEdgeInsets scrollIndicatorInsets:滚动条在scrollerView中的位置的扩展;

--float  decelerationRate:手指放开后的减速率(测试发现设定这个值没用);

============交互相关============

--Scrolling with no scroll bars is a bit complex. on touch down, we don't know if the user will want to scroll or track a subview like a control. 
on touch down, we start a timer and also look at any movement. if the time elapses without sufficient change in position, we start sending events to  the hit view in the content subview. if the user then drags far enough, we switch back to dragging and cancel any tracking in the subview. 
 the methods below are called by the scroll view and give subclasses override points to add in custom behavior.  
you can remove the delay in delivery of touchesBegan:withEvent: to subviews by setting delaysContentTouches to NO. 

--UIScrollView的事件响应顺序跟一般的不同,一般的见参考文档, UIScrollView的工作原理,当手指touch的时候,UIScrollView会拦截Event,会等待一段时间,在这段时间内,如果没有手指没有移动,当时间结束时,UIScrollView会发送tracking events到子视图上。在时间结束前,手指发生了移动,那么UIScrollView就会进行移动,从而取笑发送tracking顺序说明: 当手指touch的时候,如果scrollView上面有可交互的视图,track,->或滑动或点击   

--BOOL tracking:(readonly)returns YES if user has touched. may not yet have started dragging,即用户按上了,不管滑没滑 

--BOOL dragging:(readonly)returns YES if user has started scrolling. this may require some time and or distance to move to initiate dragging,用户在手指在scrolll时,松开了即为no了 

--BOOL decelerating:(readonly) returns YES if user isn't dragging (touch up) but scroll view is still moving 

 --BOOL delaysContentTouches:就是手指点击到类的时候,如果它为yes,则按之前讲的处理,如果为no,并且点在了“可交互的视图”,立马调用touchesShouldBegin

 --BOOL canCancelContentTouches:是if touches have already been delivered to a subview of the scroll view之后发生的事,如果no,即使touch move,也不scroll了,反之如果是yes,tracking后,手指移动,会调用touchesShouldCancelInContentView方法;

--备注:注意顺序,所以当delaysContentTouches为no,canCancelContentTouches为no的时候,touchesShouldBegin方法的返回值不同,滑动在“可交互的视图”的效果也不同,一个滑的动,一个滑不动(注意是touch move了之后的事情)   

------------相关方法------------ 

 // override points for subclasses to control delivery of touch events to subviews of the scroll view
 // called before touches are delivered to a subview of the scroll view. if it returns NO the touches will not be delivered to the subview 

- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view;// default returns YES 

--调用地方:方法在UIScrollView的子类中被重写,被调用,

--调用时候:如果delaysContentTouches为yes,则手指点击的时候,会捕获到Event,等待一段时间,在这段时间内,如果没有手指没有移动,并且手指点击在了一个“可交互的视图”则调用touchesShouldBegin,否则类scroll。如果delaysContentTouches为no,只要手指点击了,并且点在一个“可交互的视图”,立刻调用touchesShouldBegin方法。

--备注:当点击子类中的“可交互的视图”上时,如果返回值为no,点击事件不会传递给子视图了。(例如上面加了一个button,如果它返回no,点击button,没有效果)。yes反之;

 // called before scrolling begins if touches have already been delivered to a subview of the scroll view. if it returns NO the touches will continue to be delivered to the subview and scrolling will not occur 
// not called if canCancelContentTouches is NO. default returns YES if view isn't a UIControl 

- (BOOL)touchesShouldCancelInContentView:(UIView *)view; 

--调用时候,上面已讲, --返回值说明:yes,发生滚动,touch不在传递给子视图,no,不滚动,touch传递给子视图

总结: 用户touch--》tracking真--》如果点击一个可交互视图上,发生后面的事,如果没有,一般情况--》

步骤1:根据delaysContentTouches的值,判断什么时候步骤2(立刻还是判断一定条件);

步骤2:调用touchesShouldBegin方法,如果返回值为yes,touch事件传给子视图;如果为no,touch事件不传给子视图,进入状态n。(跳转) 

步骤3:touch move的,如果canCancelContentTouches为no,不调用touchesShouldCancelInContentView方法,类也不scroll,进入状态m,如果canCancelContentTouches为yes,调用touchesShouldCancelInContentView,根据touchesShouldCancelInContentView方法的返回值,如果是yes,进入状态m。如果是no,进入状态s。   

状态n:tracking为真,如果touch move的就scroll,touch松开,进入状态e 

状态s:touch move中,类scroll,如果touch 松开,进入状态e 

状态m:touch move中,类不scroll,如果touch 松开,进入状态e 

状态e:结束  

============缩放相关============  

--float minimumZoomScale:缩放的最小比例; 

--float maximumZoomScale:缩放的最大比例; 

--float zoomScale:缩放的比例(在minimumZoomScale和maximumZoomScale之间变化);如果设置的话,写在 [self.view addSubview:_scrollView];之后才能好使  

 --BOOL bouncesZoom :控制缩放到边界的时是否会反弹; 

--BOOL zooming(readonly):判断控件的大小是否正在缩放; 

--BOOL zoomBouncing(readonly):判断控件是否缩放到了最大/最小;  

--备注:如果scollView设置了缩放,但又设置contentszie等,刚开始没缩放的时候能scroll,但一但缩放过,就只能缩放,不能scroll了   

// When the user taps the status bar, the scroll view beneath the touch which is closest to the status bar will be scrolled to top, but only if its `scrollsToTop` property is YES, its delegate does not return NO from `shouldScrollViewScrollToTop`, and it is not already at the top. 
// On iPhone, we execute this gesture only if there's one on-screen scroll view with `scrollsToTop` == YES. If more than one is found, none will be scrolled.
设置单击状态栏控件是否滚动到顶部     

--BOOL scrollsToTop:


    
[3] 帧动画片
    来源: 互联网  发布时间: 2014-02-18
帧动画



 

 

准备8张图片名字分别为:loading1、loading2、loading3、loading4、

                     Loading5、loading6、loading7、loading8。

 

 

在main.xml中:

 

<LinearLayout

    android:id="@+id/group"

    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/loading"

      android:layout_marginTop="18dp"

      android:layout_width="wrap_content"

      android:layout_height="wrap_content"/>

  <Button

      android:id="@+id/start"

      android:layout_width="100dp"

      android:layout_height="40dp"

      android:layout_marginTop="30dp"

      android:background="#3399ff"

      android:textColor="#ffffff"

      android:text="开始动画"/>

</LinearLayout>

 

 

 

 

 

在res/anim下新建allloading.xml:

 

<?xml version="1.0" encoding="utf-8"?>

<animation-list

  xmlns:android="http://schemas.android.com/apk/res/android"

  android:oneshot="true">

  <item android:drawable="@drawable/loading1" android:duration="200" />

  <item android:drawable="@drawable/loading2" android:duration="200" />

  <item android:drawable="@drawable/loading3" android:duration="200" />

  <item android:drawable="@drawable/loading4" android:duration="200" />

  <item android:drawable="@drawable/loading5" android:duration="200" />

  <item android:drawable="@drawable/loading6" android:duration="200" />

  <item android:drawable="@drawable/loading7" android:duration="200" />

  <item android:drawable="@drawable/loading8" android:duration="200" />

</animation-list>

 

 

 

 

 

在MyAnimationDemo.java中:

 

package com.li.animation;

 

import android.annotation.SuppressLint;

import android.app.Activity;

import android.graphics.drawable.AnimationDrawable;

import android.os.Bundle;

import android.view.View;

import android.view.View.OnClickListener;

import android.view.animation.Animation;

import android.view.animation.AnimationUtils;

import android.widget.Button;

import android.widget.ImageView;

 

 

@SuppressLint({ "ParserError", "ParserError" })

public class MyAnimationDemo extends Activity {

  private ImageView loading = null;

  private Button start = null;

  private AnimationDrawable draw = null;

    @Override

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        super.setContentView(R.layout.main);

        this.loading = (ImageView)super.findViewById(R.id.loading);

        this.start = (Button)super.findViewById(R.id.start);

        this.start.setOnClickListener(new OnClickListenerImpl());

    }

    private class OnClickListenerImpl implements OnClickListener{

     public void onClick(View v) {

       MyAnimationDemo.this.loading.setBackgroundResource(R.anim.allloading);

       MyAnimationDemo.this.draw = (AnimationDrawable)MyAnimationDemo

            .this.loading.getBackground();

       MyAnimationDemo.this.draw.setOneShot(false); //一直动

       MyAnimationDemo.this.draw.start();

     }

    }

}

 


    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
Web服务器/前端 iis7站长之家
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3