編輯:關於Android編程
package com.ttw.gif;
import java.io.IOException;
import java.io.InputStream;
import com.ttw.androidhtppclient.Utility;
import android.content.Context;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Movie;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
public class GifMove extends View {
private Movie mMovie;
private InputStream is = null;
private long mMovieStart;
public GifMove(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public GifMove(Context context, AttributeSet attrs) {
super(context, attrs);
}
public GifMove(Context context) {
super(context);
}
public void setGifSource(int source) {
BitmapFactory.Options option = new BitmapFactory.Options();
option.inJustDecodeBounds = true;
BitmapFactory.decodeResource(getResources(), source, option);
Utility.logI("move widht = " + option.outWidth + " height = " + option.outHeight);
LayoutParams lp = this.getLayoutParams();
lp.width = option.outWidth;
lp.height = option.outHeight;
this.setLayoutParams(lp);
if(null != is){
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}finally{
is = null;
}
}
is = getResources().openRawResource(source);
mMovie = Movie.decodeStream(is);
}
@Override
protected void onDraw(Canvas canvas) {
long now = android.os.SystemClock.uptimeMillis();
if (mMovieStart == 0) {
mMovieStart = now;
}
if (mMovie != null) {
int dur = mMovie.duration();
if (dur == 0) {
dur = 500;
}
int relTime = (int) ((now - mMovieStart) % dur);
mMovie.setTime(relTime);
mMovie.draw(canvas, getWidth() - mMovie.width(), getHeight()
- mMovie.height());
invalidate();
}
super.onDraw(canvas);
}
1.Volley結構圖從上圖可以看到Volley分為三個線程,分別是主線程、緩存調度線程、和網絡調度線程,首先請求會加入緩存隊列,如果發現可以找到相應的緩存結果就直接讀取
本文將用兩個方法來寫類似汽車荷載的進度用LinearLayout的addview方法加上for循環用自定義控件的方法先上截圖1. 用LinearLayout的addvie
上一篇文章《CoordinateLayout的使用如此簡單 》對CoordinateLayout的使用做了講解,今天我們再講解常常與其一起使用的幾個View:AppBar
百度官方文檔:http://lbsyun.baidu.com/index.php?title=androidsdk使用步驟:下載百度地圖的SDK +申請密鑰 環境配置(