Creating the app layout and components

In your activity_main.xml file, which resides in your assets/layouts folder, you need to input the following code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.avinaas.imagelabelling.MainActivity">

<TextureView
android:id="@+id/preview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/btn_takepic"
android:layout_alignParentTop="true"/>

<Button
android:id="@+id/btn_takepic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp"
android:text="Start Labeling"
/>
</RelativeLayout>
In the preceding XML tools, the context value needs to change with your main activity.

In the preceding XML, we have added a button to receive events, and a texture view, which serves as a placeholder for the camera stream.

The design view of the preceding layout will look like this:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset