Search code examples
androidviewandroid-linearlayoutandroid-custom-view

About extending LinearLayout


I need to create a View which extends a LinearLayout to contain some standard android widget. I've created a class MyLinearLayout which extends the LinearLayout class; but now, how can I use it as an element in the xml layout file? I can't get it working and I haven't been able to find info about it and so I'm a bit confused... O.O


Solution

  • Assuming

    package com.example;
    
    public class MyLinearLayout extends LinearLayout...
    

    in your xml you can use

    <com.example.MyLinearLayout
       android:id="@+id/MyLayout"
       [rest of attributes go here]
    >
    [other stuff here]
    </com.example.MyLinearLayout>