Android: how to customize view layout using XML

I come from the world of GWT and uibinder. I am used to defining custom components by extending composite, and then putting all UI layout code in mycomponent.ui.xml file. This is a very good way to build components from smaller components

I'm trying to use a custom view to achieve the same effect on Android. I've been able to programmatically extend the view and then add objects by calling addview (textview). I hope to achieve this in XML, but I don't see how to associate the XML layout file with the view (except the main res / layout / main.xml file, which provides the main layout of the application)

How do I lay out custom views in XML?

Editor: my question is not clear. What I have to do is to_ The widget.xml file is associated with my custom view. Then in my_ In widget.xml, I want to define various textviews and insert them into my view class

resolvent:

To construct a view from XML, use layoutinflator

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>