绑定的Android定制以特定的布局XML(这甚至可能吗?) [英] Bind android custom view to a specific layout xml (is this even possible?)
问题描述
我想提出一个自定义视图多次在我的main.xml中它由一个RelativeLayout的,一些控件,然后我的自定义视图。 这个自定义视图应使用以下(简体)XML:
I'd like to put a custom view multiple times in my main.xml which consists of a RelativeLayout, some controls and then my custom view. This custom view should use the following (simplified) xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="220px"
android:layout_height="220px"
android:background="@drawable/contextitemshape">
<TextView
android:text="some caption"
android:textSize="23px"
android:textColor="#000000"/>
<FrameLayout
android:id="@+id/content"/>
</RelativeLayout>
我怎样才能得到它使用它创建每次这个文件?是,即使有可能在Android的?所有的自定义视图我能找到不使用自己的布局xml文件。
How can I get it to use this file each time it is created? Is that even possible in android? All the custom views I can find don't use an own layout-xml file.
感谢您!
推荐答案
有您的自定义查看
膨胀的布局作为其设置的一部分。 这里是一个项目,除其他外,实现了一个 ColorMixer
自查看
的膨胀包含三个搜索栏
部件和一些其他的东西的布局。
Have your custom View
inflate the layout as part of its setup. Here is a project that, among other things, implements a ColorMixer
custom View
that inflates a layout containing three SeekBar
widgets and some other stuff.
这篇关于绑定的Android定制以特定的布局XML(这甚至可能吗?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!