1
我有一个自定义视图类
public class Zoom extends View {
private Drawable image;
private int zoomControler=20;
public Zoom(Context context)
{
super(context);
image=context.getResources().getDrawable(R.drawable.icon);
setFocusable(true);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//TransparentPanel tp = new TransparentPanel(this.getContext());
//Button MyButton = new Button(this.getContext());
//MyButton.setText("Press me");
//tp.addView(MyButton);
image.setBounds((getWidth()/2)-zoomControler, (getHeight()/2)-zoomControler, (getWidth()/2)+zoomControler, (getHeight()/2)+zoomControler);
image.draw(canvas);
}
}
我可以使用的setContentView(R.layout.mylayout)在这个自定义视图来显示设计?
或
怎么可以与图像的OnDraw方法显示按钮正如我已经注释的代码?
任何帮助,将不胜感激。