WEB开发网
开发学院手机开发Android 开发 Android 获取XML,DRAWABLE资源 阅读

Android 获取XML,DRAWABLE资源

 2012-07-01 09:41:10 来源:WEB开发网   
核心提示:.widget.ImageView;public class Drawable1Activity extendsActivity {/** Called when the activity is first created. */@Overridepublic void onCreate(Bundle savedIns
.widget.ImageView;
public class Drawable1Activity extends
Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(
Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources resources = getResources();
TransitionDrawable transitionDrawable = (TransitionDrawable) resources
.getDrawable(R.drawable.photo);
ImageView mImageView = (ImageView) findViewById(R.id.imageView1);
mImageView
.setImageDrawable(transitionDrawable);
transitionDrawable
.startTransition(5000);
}
}

--------------画椭圆
package gongzibai.co.cc;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.view.View;
public class Cview extends View {
private ShapeDrawable shapeDrawable;
public Cview(Context context) {
super(context);
// TODO Auto-generated constructor stub
int x = 10;
int y = 10;
int width = 300;
int height = 50;
shapeDrawable = new ShapeDrawable(
new OvalShape());
shapeDrawable.getPaint()
.setColor(Color.RED);
shapeDrawable.setBounds(x, y, x
+ width, y + height);
}
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
shapeDrawable.draw(canvas);
super.onDraw(canvas);
}
}
-------Cview
package gongzibai.co.cc;
import android.app.Activity;
import android.os.Bundle;
public class Drawable1Activity extends
Activity {
private Cview cview;
/** Called when the activity is first created. */
@Override
public void onCreate(
Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
cview=new Cview(this);
setContentView(cview);
}
}

上一页  1 2 

Tags:Android 获取 XML

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接