开发者

How do I override OnDraw of ImageView when using XML layout?

I'm new to Android, but frus开发者_JAVA百科trated with what seems a basic question, so apologies if this is a stupid question...

I need to override onDraw for an ImageView (to draw dots on the image), I can do this, but I also want to add a button to the screen.

I've created an ImageView in my code and setContentView(myImageView). But how do I add a button under this image? Ideally, I'd like to call everything from XML, but I don't think I'd be able to override onDraw for the image if I did that?

Perhaps I could create a Layout in the code, then add the image and button dynamically to my layout, then setContentView(layout)?

Thanks


You can create a custom view, override the onDraw() method and use it from XML:

<com.my.package.MyCustomView />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜