Tutorial — Create the App layout
This section shows you how to create the layout for the app.
Create the layout
Open activity_main.xml
and insert the following xml mark up. This creates your screen layout.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainpage"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.samsung.knox.example.container.MainActivity">
<TextView
android:id="@+id/logview_id"
android:gravity="bottom"
android:layout_width="320dp"
android:layout_height="230dp"
android:textColor="#3F51B5"
android:background="@drawable/background"
android:scrollbars="vertical"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:layout_marginTop="22dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<Button
android:id="@+id/createAndroidProfileBtn"
android:layout_width="210dp"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:layout_below="@+id/logview_id"
android:layout_centerHorizontal="true"
android:text="@string/android_po" />
<Button
android:id="@+id/activateLicenseBtn"
android:layout_width="210dp"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/createAndroidProfileBtn"
android:layout_below="@+id/createAndroidProfileBtn"
android:text="@string/activate_license" />
<Button
android:id="@+id/deactivateLicenseBtn"
android:layout_width="210dp"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/activateLicenseBtn"
android:layout_below="@+id/activateLicenseBtn"
android:text="@string/deactivate_license" />
<Button
android:id="@+id/toggleCameraBtn"
android:layout_width="210dp"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/deactivateLicenseBtn"
android:layout_below="@+id/deactivateLicenseBtn"
android:text="@string/toggle_camera" />
<Button
android:id="@+id/enforceMfaBtn"
android:layout_width="210dp"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/toggleCameraBtn"
android:layout_below="@+id/toggleCameraBtn"
android:text="@string/enforce_mfa" />
</RelativeLayout>
You now see 5 buttons in the middle of the screen. CREATE MANAGED PROFILE, ACTIVATE LICENSE, DEACTIVATE LICENSE, TOGGLE CONTAINER CAMERA, and ENFORCE MULTI-FACTOR AUTHENTICATION. You will later assign methods to these buttons to control their respective actions. There is also a TextView
at the top of the screen that will display any log messages.
To resolve the @string
errors, copy the strings.xml file from the sample app into your project.
For information on creating Android layouts, see Create your first Android app.
Tutorial progress
You’ve completed 2/7 steps!
NextOn this page
Is this page helpful?