我可以,如果我這樣做,這個標誌添加到canavas:嘗試通過FrameLayout.addView()將Imageview添加到畫布上;
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(200,200);
ImageView boo = new ImageView(ExampletouchActivity.this);
boo.setImageResource(R.drawable.ic_launcher);
boo.setLayoutParams(lp);
fr.addView(boo); //this works fine
但是,如果我嘗試在同一徽標添加到畫布這樣它不會顯示任何東西:
fr.addView(new Toucher(ExampletouchActivity.this));
我Toucher類是這樣的...
public class Toucher extends View{
ImageView boo;
public Toucher(Context context)
{
super(context);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(200,200);
boo = new ImageView(context);
boo.setImageResource(R.drawable.ic_launcher);
boo.setLayoutParams(lp);
}
@Override
public void onDraw(Canvas c)
{
boo.draw(c);
}
我一直在嘗試的年齡,不能明白爲什麼這個ImageView的本身不會畫到畫布?
很多謝謝