How to build a simple user interface in Android?

In this lesson, you learn how to use the Android Studio Design Editor to create a layout that contains a text box and a button. This establishes the basis for the following lesson, in which you will learn how to have the app communicate the content of the text box to another activity when the button is clicked. You can opt an Android app training in Kochi to learn all about Android development from scratch and build a strong base in mobile app development.

The user interface (UI) of an Android app is made up of a hierarchy of layouts and widgets. View Group objects, which control how their child views are positioned on the screen to create the layouts. Widgets are View objects that include UI components like buttons and text boxes. Android includes an XML vocabulary that corresponds to View and View Group sub classes, allowing you to build your UI in XML using a hierarchy of UI components. View Group sub classes are Layouts. You’ll be working with a Linear Layout in this task.

Create a Linear Layout

Open the myactivity.xml file in Android Studio from the res/layout directory. When you started this project, you picked the Empty Activity template, which includes the myactivity.xml file, which contains a Relative Layout root view and a Text View child view. When you open a layout file in Android Studio, the Preview window appears first. When you click an element in this pane, the WYSIWYG (What You See Is What You Get) tools in the Design pane appear.

Get rid of the <TextView> element.

Change the element <RelativeLayout> to LinearLayout>.

Set the android:orientation property to “horizontal.”

<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”

xmlns:tools=”http://schemas.android.com/tools”

Android training in Kochiandroid:layout_width=”match_parent”

android:layout_height=”match_parent”

android:orientation=”horizontal” >

<EditText android:id=”@+id/edit_message”

android:layout_width=”wrap_content”

android:layout_height=”wrap_content”

android:hint=”@string/edit_message” />Android training in Kochi

<Button

android:layout_width=”wrap_content”

android:layout_height=”wrap_content”

android:text=”@string/button_send” />

</LinearLayout>

Run the App : Click Run from the toolbar in Android Studio.

Android UI designing is simple with XML structure. You can also use drag and drop options to create attractive and effective user interfaces for your application. You can choose an Android training in Kochi and build your Android apps with full hands-on experience and practice.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store