In this tutorial will teach you how to make a registration form design in android studio step by step. This tutorial will help you learn android UI and and Toast message displayed.
Design the UI Design
Android studio folder structure there is folder which is res this is the folder will help us to make a UI Design of the App.inside res folder you can see the layout folder if you expand the layout folder there is a file
activity_main.xml
in this file we will design App Layout i have design the registration UI design below.
activity_main.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:orientation="vertical" android:background="@color/colorPrimary"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="30dp" android:gravity="center" android:text="@string/title" android:textSize="35dp" android:textColor="@color/colorwhite" /> <ImageView android:layout_width="100sp" android:layout_height="100sp" android:src="@drawable/reg" android:gravity="center" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:text="@string/name" android:textSize="20dp" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/name" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:text="@string/address" android:textSize="20dp" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/address" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:text="@string/phone" android:textSize="20dp" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/phone" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:text="@string/email" android:textSize="20dp" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/email" /> </LinearLayout> <Button android:id="@+id/btnk" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/btnok" /> </LinearLayout> </LinearLayout> |
MainActivity
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends AppCompatActivity { EditText ed1,ed2,ed3,ed4; Button btnOk; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ed1 = findViewById(R.id.name); ed2 = findViewById(R.id.address); ed3 = findViewById(R.id.phone); ed4 = findViewById(R.id.email); btnOk = findViewById(R.id.btnk); btnOk.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String name = ed1.getText().toString(); String address = ed2.getText().toString(); String phone = ed3.getText().toString(); String email = ed4.getText().toString(); String txt = "Your Name is " + "\t" + name + "\n" + "Your Address is " + "\t" + address + "\n" + "Your Phone No is " + "\t" + phone + "\n" + "Your Email ID is " + "\t" + email + "\n"; Toast.makeText(MainActivity.this,txt.toString(),Toast.LENGTH_LONG).show(); } }); } } |
i have attached the video link below. which will do this tutorials step by step.