Simple User Interface

How to build a simple user interface in android apps

In my previous lesson, we learn how to run Android applications.Today we are going to a simple user interface.We will add TextView, linearlayoutButtons, etc.

Android graphical user interface is made up of Views(Buttons and Textfields) and ViewGroup.

Layout subclasses are contained in the ViewGroup.This exercise linear layout.

Diagram showing View group in a layout

Simple User Interface

 

Steps to simple user interface in Android

1.Create Layout.

Open android Studio project and go to app > res > layout > activity_main.xml.

This file defines your application Layout.

Delete all the content and add below XML file.

There are two attributes that are very import here.android:layout_width and android:layout_height.

match_parent attribute makes the layout to occupy the whole screen.

2.Adding TextFields to the Layout.

In the activity_main.xml file ,add the following  elements .All of them are EditText.All of them takes string variables.TextFields to be added Name,Email and Message.

Dont worry about the error that  appears because of  android:hint=”@string/edit_message” and others.They will be fixed once we add string Resources.


3.Add String Resources:

In your project window,open  res > values > strings.xml. and add below code.

 4.Add Button

This is the last step.Add below button code to activity_main.xml file.

Once you run your application you should see below screen on your device.Simple android user interface

 

 

About the Author: Eric K

Kenyan Developer and Blogger with Interests in Java,Javascript,Node.js, Wordpress, Android, PHP and Making Money Online. Solving world problems through programming is my passion. Hire me: Email : kawi3462@gmail.com