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 find 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With