开发者

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

开发者 https://www.devze.com 2023-02-17 14:28 出处:网络
I\'m new to Android, but frus开发者_JAVA百科trated with what seems a basic question, so apologies if this is a stupid question...

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

精彩评论

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