Creating basic Android app part-1

In this post we will learn how to make basic android app, for making android app you need below software

1) JDK (Java environment).
you can check whether your system already has java environment by writing this command
"javac -version"

2) Android Studio

After installing the above things, you can proceed to create your own basic android app.

Open Android Studio and create the new Android project , after you create the new project you will see the app folder, inside that you will find Java folder, res folder and so on.

Now we will create the simple basic user interface for our android app.

To create the user interface we need to write code inside activity_main.xml which is inside app->res->layout folder.

Before we proceed to create a simple UI by writing code inside the xml we will first learn more about the UI layout and terms associated with it.

we will first talk about View and ViewGroups


The graphical user interface for an Android app is built using a hierarchy of View and ViewGroups
View objects are usually UI widgets such as buttons or textfields. ViewGroup objects are invisible view containers that define how the child views are laid out, such as in a grid or a vertical list.

Android provides an XML vocabulary that corresponds to the subclasses of View and ViewGroup so you can define your UI in XML using a hierarchy of UI elements.

Now we can go ahead and write code to create the very first UI for your android app

Activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:orientation="horizontal">
<EditText android:id="@+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="string/button_send" />
</LinearLayout>
Run this code in emulator and see the output.

Here you go you have made your first UI for your android app, now you can modify the codein your xml file and create your own UI.

Comments

Popular posts from this blog

Tricky Questions or Puzzles in C

Program to uncompress a string ie a2b3c4 to aabbbcccc

Number series arrangement puzzles