views:

25

answers:

2

I have a small xml file called 'xmlview.xml' which is something like:

<tablelayout>
   <tablerow>
      <view id="view1" />

I created a class which extends view, and I inflated that xml file and now i have a view obtained due to inflation.

xmlView = layoutInflater.inflate(R.layout.xmlview, this);

I am wondering is there a way to draw on the view 'view1' inside the view 'xmlview'

I tried something like:

View view1 = (View)xmlview.findById(R.Id.view1);

and then I tried in the overriden onDraw to draw on view1 but nothing worked,

any ideas ??

A: 

I'm not sure what exactly you mean by "draw on the view", but it sounds like you should be looking into the Canvas. You should not arbitrarily override the onDraw method, this is what causes your widgets to appear on the screen.

Mayra
A: 

Hey Mayra, Thank you for your reply.

If you take a look at the section "ShapeDrawable" here,

you will find an example of what I am trying to do, except I am trying to do it from xml, which is described in the lines:

If you'd like to draw this custom drawable from the XML layout instead of from the Activity, then the CustomDrawable class must override the View(Context, AttributeSet) constructor, which is called when instantiating a View via inflation from XML.

However I am not able to do what they are describing.

Any input will be appreciated.

Thanks

Kerric