how to add shapes using java code to a xml layout?
As per my requirement I need to add tow rectangles in a existing xml layout through java code. I can create the rectangle shapes usi开发者_StackOverflow社区ng ondraw method, but using intents in fresh layout. I need to display that shapes in existing layout. If any one faces this experience, please help me to create shapes in a xml. Any responce would be appreciated.
Thanks in advance
If the rectangles have a predefined place and size it it only a question of changing the visibility at runtime.
Give the rectangle the attribute android:visibility="gone" in the xml, and from the code use the setVisibility(View.VISIBLE) on the reference to the widget when you want to show it. In this way you may hide it again when no longer needed.
If this answer does not help you please specify more details and I may be able to help you better.
BR,
Vanja
精彩评论