If DrawV
is an Android View (or extends View), you can include it in a regular xml layout file, and then use that layout file with setContentView(int)
.
To reference the DrawV
class in your layout, you'll need to use the fully-qualified name (with the package).
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/button_one"
android:text="One"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0" />
<Button
android:id="@+id/button_two"
android:text="Two"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0" />
</LinearLayout>
<com.example.views.DrawV
android:layout_below="@id/buttons"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
Above, the RelativeLayout is your root view. The LinearLayout, buttons
, is a ViewGroup just to hold the two buttons and keep them of equal width (note the layout_width=0dp
and equal layout_weight
). Your DrawV
view will be laid out below the buttons
View, and then will match the parent container's width and height (fill it).
If you save this under src/main/res/layout/activity_circles.xml
, you'll be able to use setContentView(R.layout.activity_circles)
in your Activity to set the layout.