Can I create an xml file with a view without the layout containing


I have a custom view called CustomImageView.

I would like to create an xml file with this view so I inflate the view and add it programmatically to my current layout. (depending on orientation , I will decide where to add it)

Is it possible to so something like this in the xml without a containing layout

<?xml version="1.0" encoding="utf-8"?>
    android:anotherattr="adsad" />

After that I will inflate it. or should I put it in a Layout like LinearLayout? I just want an xml with my view so I can inflate it and add to my existing layout.. I am not sure what the containing layout would be!

This is perfectly legitimate. You can do it with built-in or custom views. Here is an example from the Android framework. It's an xml layout file containing a single TextView, representing a default ListView row layout. The TextView has several attributes assigned to it in xml, just as your custom view will.