Skip to main content


Showing posts from June, 2016

Adding custom view to xml

You wanted to write your own custom view. You wrote it extending View class or better still TextView or ImageView class. You even added this view within your activity using Java code and tested it successfully.

But adding views with Java is a lengthy process and is cumbersome. xml makes the process easier. 

So how do you add your custom view into your layout xml file?

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- Other Views --> < android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/cell1"/> <!-- Other Views --> </LinearLayout>
OK, thi…