Skip to main content

Posts

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 an d tested it successful ly. 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? somelayout.xml  <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- Other Views --> <com.some.name.CustomView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/cell1"/> <!-- Other Views --> </LinearLayo