开发者

Bind android custom view to a specific layout xml (is this even possible?)

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>

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 fin开发者_JAVA百科d don't use an own layout-xml file.

Thank you!


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜