Creating BoxDrawingView
Next, update your fragment_drag_and_draw.xml layout file to use your new view.
Listing 31.4 Adding BoxDrawingView to layout
(fragment_drag_and_draw.xml)
<android.support.constraint.ConstraintLayout
android:id="@+id/activity_drag_and_draw"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.bignerdranch.android.draganddraw.DragAndDrawActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="@+id/activity_drag_and_draw"
app:layout_constraintLeft_toLeftOf="@+id/activity_drag_and_draw"
app:layout_constraintRight_toRightOf="@+id/activity_drag_and_draw"
app:layout_constraintTop_toTopOf="@+id/activity_drag_and_draw"/>
android:layout_width="match_parent"
android:layout_height="match_parent" />
You must use BoxDrawingView’s fully qualified class name so that the layout inflater can find it. The
inflater works through a layout file creating View instances. If the element name is an unqualified class
name, then the inflater looks for a class with that name in the android.view and android.widget
packages. If the class lives somewhere else, then the layout inflater will not find it, and your app will
crash.
So, for custom classes and other classes that live outside of android.view and android.widget, you
must always specify the fully qualified class name.