开发者

Android xml layout and adding a custom view written in xml

开发者 https://www.devze.com 2023-03-30 17:10 出处:网络
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?

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" />

...

0

精彩评论

暂无评论...
验证码 换一张
取 消