Android Note 2011.08.01
*变换图片 TransitionDrawable
<?xml version="1.0" encoding="UTF-8"?>
<transition xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/sample_0"/>
<item android:drawable="@drawable/sample_1"/>
</transition>
Resources res=getResources();
TransitionDrawable transition= (TransitionDrawable)res.getDrawable(R.drawable.transition);
ImageView view=new ImageView(this);
view.setImageDrawable(transition);
transition.startTransition(1000);
*绘制形状 ShapeDrawable
public class MyView:View{
private ShapeDrawable shape;
public MyView(Context c){
super(c);
shape=new ShapeDrawable(new OvalShape);
shape.getPaint().setColor(0xffffffff);
shape.setBounds(0,0,100,199);
}
@Override
public void onDraw(Canvas canvas){
shape.draw(canvas);
}
}
*操作assets中的文件
ImageView img=new ImageView(this);
setContentView(img);
AssetManager manager=this.getAssets();
String[] files;
try {
files=manager.list("");
InputStream file= manager.open(files[1]);
img.setImageBitmap(BitmapFactory.decodeStream(file));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}