简体   繁体   English

如何将XML布局包含到Android库中

[英]How to include an XML Layout into an Android library

Basically I am trying to make an Android library which needs to have an XML Layout. 基本上,我正在尝试制作一个需要具有XML布局的Android库。

But the problem I am facing is that I cannot see an Layout Folder under my res folder. 但是我面临的问题是我在res文件夹下看不到布局文件夹。

Till now I have figured out that a custom view can be made and used using a Java Class, but I am not in an favour of using this method as I am not very knowledgeable in making layouts using java. 到现在为止,我已经知道可以使用Java类来创建和使用自定义视图,但是我不赞成使用此方法,因为我不太了解如何使用Java进行布局。

My research till now has given me an Idea that Is it possible for my Library class to accept an layout and the ids of views inside the layout and then use them as needed. 到目前为止,我的研究已经使我想到,我的Library类是否可以接受布局以及布局中视图的ID,然后根据需要使用它们。

OR 要么

Is there any other way of doing it? 还有其他方法吗?

Any Help would be really appreciated. 任何帮助将非常感激。

But the problem I am facing is that I cannot see an Layout Folder under my res folder. 但是我面临的问题是我在res文件夹下看不到布局文件夹。

You are welcome to create a res/layout/ directory yourself. 欢迎您自己创建一个res/layout/目录。 There are an infinite number of resource directories; 资源目录的数量是无限的。 few will be created for you when you create your project. 创建项目时,将为您创建的项目很少。

You can use the file manager that is part of your desktop OS to create this directory. 您可以使用桌面操作系统中的文件管理器来创建此目录。 Or, from Android Studio, you can right-click over the res/ directory, choose New > Directory from the context menu, and enter layout for the name. 或者,您可以在Android Studio中右键单击res/目录,从上下文菜单中选择“新建”>“目录”,然后输入名称的layout

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM