Android xml layout and adding a custom view written in xml
I've created a custom view XM开发者_如何学CL layout resource MyView.xml
. Can I refer to MyView
by the XML layout file inside a second XML layout such as main.xml
? If so, how?
(To be clear, I'm not looking for replies that explain how to inflate views from within my Java code, or that explain introducing Java classes in XML layout resources with <com.MyDomain.App.MyView ...>
unless this helps here or to clarify that I have no other option.)
If your XML file is like /res/layout/MyView.xml
you can refer to in main.xml
with
<?xml version=”1.0” encoding=”utf-8”?>
...
<include layout="@layout/MyView.xml" />
...
精彩评论