2

I've been working on this for a while but can't find anything that exactly addresses my question (at least not something easy to understand).

I have a main layout XML file where I define various layout objects like a Button or a TextView (and I know I can add SurfaceView, View, and view and other things too). I want to draw a shape (in my case it's an arc) in just one of these objects so it doesn't take up the whole screen and so I can position it relative to other things.

(In my case it will ultimately re-draw the arc kind of like a circle with a gap in a different position every time I call a method depending on a value I pass to the method, but that's separate from my basic question.)

I know the answer will have something to do with a canvas, an onDraw method, maybe Paint, probably a view. I have been able to draw a circle from a custom View object by setting the main java file's layout as that View (as opposed to R.layouts.main), but that takes up the whole screen, and I'm unsure how I might be able to have that dynamically draw with modifications.

A really clear explanation or better yet an actual example would just be awesome.

4

1 回答 1

3

如我所见,您需要在小部件上而不是在整个屏幕上绘制特定形状。尝试使用图层列表。您可以参考此链接获取示例链接

于 2013-03-12T08:08:07.577 回答