0% found this document useful (0 votes)
70 views10 pages

Localhost/Androidapp/Api PHP

This PHP file defines an API for an Android application to handle user signup and login. It connects to a MySQL database, checks if a user's email already exists during signup, inserts new user data or logs in an existing user, and returns the response as JSON. It also includes an AndroidManifest.xml file defining app components and permissions, a SQL file defining the users table schema, and Java classes for making web requests and defining a global class.

Uploaded by

Takako Andey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views10 pages

Localhost/Androidapp/Api PHP

This PHP file defines an API for an Android application to handle user signup and login. It connects to a MySQL database, checks if a user's email already exists during signup, inserts new user data or logs in an existing user, and returns the response as JSON. It also includes an AndroidManifest.xml file defining app components and permissions, a SQL file defining the users table schema, and Java classes for making web requests and defining a global class.

Uploaded by

Takako Andey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Localhost/androidApp/api.

php
<?php
// step 1: connect to database
// mysqli_connect function has 4 params (host,user name, password,database_name)
$db_con = mysqli_connect("localhost","root","","android_app");

$response = array();
header('Content-Type: application/json');

if(mysqli_connect_errno())
{
$response["error"] = TRUE;
$response["message"] ="Faild to connect to database";
echo json_encode($response);
exit;
}

//rubah &amp;&amp; jadi && karena gak suport


if(isset($_POST["type"]) &&
($_POST["type"]=="signup") &&
isset($_POST["name"]) &&
isset($_POST["email"]) &&
isset($_POST["password"])){
// signup user
$name = $_POST["name"];
$email = $_POST["email"];
//$password = md5($_POST["password"]);
$password = $_POST["password"];

//check user email whether its already regsitered


$checkEmailQuery = "select * from users where email = '$email'";
$result = mysqli_query($db_con,$checkEmailQuery);
// print_r($result); exit;
if($result->num_rows>0){
$response["error"] = TRUE;
$response["message"] ="Sorry email already found.";
echo json_encode($response);
exit;
}else{
$signupQuery = "INSERT INTO users(name,email,password)
values('$name','$email','$password')";
$signupResult = mysqli_query($db_con,$signupQuery);
if($signupResult){
// Get Last Inserted ID
$id = mysqli_insert_id($db_con);
// Get User By ID
$userQuery = "SELECT id,name,email FROM users WHERE id = ".$id;
$userResult = mysqli_query($db_con,$userQuery);

$user = mysqli_fetch_assoc($userResult);

$response["error"] = FALSE;
$response["message"] = "Successfully signed up.";
$response["user"] = $user;
echo json_encode($response);
exit;
}else{
$response["error"] = TRUE;
$response["message"] ="Unable to signup try again later.";
echo json_encode($response);
exit;
}

}
if(isset($_POST["type"]) &&
($_POST["type"]=="login") &&
isset($_POST["email"]) &&
isset($_POST["password"])){
//login user

$email = $_POST["email"];
$password = $_POST["password"];

$userQuery = "select id,name,email from users where email = '$email' && password =
'$password'";
$result = mysqli_query($db_con,$userQuery);
// print_r($result); exit;
if($result->num_rows==0){
$response["error"] = TRUE;
$response["message"] ="user not found or Invalid login details.";
echo json_encode($response);
exit;
}else{
$user = mysqli_fetch_assoc($result);
$response["error"] = FALSE;
$response["message"] = "Successfully logged in.";
$response["user"] = $user;
echo json_encode($response);
exit;
}

}
else {
// Invalid parameters
$response["error"] = TRUE;
$response["message"] ="Invalid parameters";
echo json_encode($response);
exit;
}
?>

Android_app.sql
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for users
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`email` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`created_at` datetime(0) NOT NULL DEFAULT current_timestamp(0),
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci
ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
Androidmanifast proguardFiles
<?xml version="1.0" encoding="utf-8"?> getDefaultProguardFile('proguard-android-
<manifest optimize.txt'), 'proguard-rules.pro'
xmlns:android="http://schemas.android.com/apk }
/res/android" }
package="com.koiwai.loginsingup">
<uses-permission }
android:name="android.permission.INTERNET"/>
<application dependencies {
android:allowBackup="true" implementation fileTree(dir: 'libs',
android:icon="@mipmap/mata" include: ['*.jar'])
android:label="@string/app_name"
android:roundIcon="@mipmap/mata" implementation
android:supportsRtl="true" 'androidx.appcompat:appcompat:1.1.0'
android:theme="@style/AppTheme"> implementation
<activity 'androidx.constraintlayout:constraintlayout:1
android:name=".MainActivity"></activity> .1.3'
<activity testImplementation 'junit:junit:4.12'
android:name=".SplashActivity" androidTestImplementation
'androidx.test.ext:junit:1.1.1'
android:screenOrientation="fullSensor"> androidTestImplementation
<intent-filter> 'androidx.test.espresso:espresso-core:3.2.0'
<action implementation
android:name="android.intent.action.MAIN" /> 'com.loopj.android:android-async-http:1.4.9'
implementation
<category 'com.squareup.picasso:picasso:2.5.2'
android:name="android.intent.category.LAUNCHE }
R" />
</intent-filter>
</activity>
<activity GlobalClass
android:name=".LoginActivity" package com.koiwai.loginsingup;

android:screenOrientation="fullSensor" /> import android.app.Application;


<activity
android:name=".SignupActivity" public class GlobalClass extends Application
{
public static final String BASE_URL =
android:screenOrientation="fullSensor" /> "http://192.168.100.64/androidApp/";
<activity // public static final String BASE_URL =
android:name=".HomeActivity" "http:/localhost:8888/androidApp/api.php";

android:screenOrientation="fullSensor"></acti private static GlobalClass singleton;


vity> @Override
</application> public void onCreate() {
</manifest> super.onCreate();
singleton =this;
}
Build.gradle public static GlobalClass getInstance() {
return singleton;
apply plugin: 'com.android.application' }
}
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"

defaultConfig { WebReq
applicationId
"com.koiwai.loginsingup" package com.koiwai.loginsingup;
minSdkVersion 16
targetSdkVersion 29 import android.content.Context;
versionCode 1 import android.util.Log;
versionName "1.0"
import }
com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.RequestParams;
import //concatenation of base url and file
com.loopj.android.http.ResponseHandlerInterfa name
ce; private static String
getAbsoluteUrl(String relativeUrl) {
public class WebReq { Log.d("response URL:
public static AsyncHttpClient client; ",GlobalClass.getInstance().BASE_URL +
relativeUrl+" ");
static{ return
//create object of loopj client GlobalClass.getInstance().BASE_URL +
//443 will save you from ssl relativeUrl;
exception }
client = new
AsyncHttpClient(true,80,443); public static void post(Context context,
} String url, RequestParams params,
ResponseHandlerInterface responseHandler) {
public static void get(Context context, client.post(context,
String url, RequestParams params, getAbsoluteUrl(url), params,
ResponseHandlerInterface responseHandler) { responseHandler);
client.post(context, }
getAbsoluteUrl(url), params, }
responseHandler);

MainActivity Matcher matcher =


pattern.matcher(email);
package com.koiwai.loginsingup; return matcher.matches();
}
import
androidx.appcompat.app.AppCompatActivity; public void init() {
sharedPreferences =
import android.content.Context; getSharedPreferences(SHARED_PREF_NAME,MODE_P
import android.content.Intent; RIVATE);
import android.content.SharedPreferences; sharedPrefEditor =
import android.os.Bundle; sharedPreferences.edit();
import android.view.MenuItem; }

import java.util.regex.Matcher; @Override


import java.util.regex.Pattern; public boolean
onOptionsItemSelected(MenuItem item) {
public class MainActivity extends switch (item.getItemId()) {
AppCompatActivity { case android.R.id.home:
Context context; finish();
Intent intent; default:
SharedPreferences sharedPreferences; return
String SHARED_PREF_NAME ="user_pref"; super.onOptionsItemSelected(item);
SharedPreferences.Editor }
sharedPrefEditor; }
protected String name,email,password; }

protected boolean isLoggedIn(){


return
sharedPreferences.getBoolean("login",false);
}

protected void logout(){

sharedPrefEditor.putBoolean("login",false);
sharedPrefEditor.apply(); SplashActivity
sharedPrefEditor.commit();
} package com.koiwai.loginsingup;

import
public static boolean isEmailValid(String androidx.appcompat.app.AppCompatActivity;
email) {
String expression = "^[\\w\\.-] import android.content.Intent;
+@([\\w\\-]+\\.)+[A-Z]{2,4}$"; import android.os.Bundle;
Pattern pattern =
Pattern.compile(expression, import java.util.Timer;
Pattern.CASE_INSENSITIVE); import java.util.TimerTask;
setContentView(R.layout.activity_home);
public class SplashActivity extends getViews();
MainActivity { }
private void getViews() {
@Override nameTv = findViewById(R.id.nameTv);
protected void onCreate(Bundle
savedInstanceState) { nameTv.setText(sharedPreferences.getString("n
super.onCreate(savedInstanceState); ame",""));
init(); emailTv = findViewById(R.id.emailTv);

setContentView(R.layout.activity_splash); emailTv.setText(sharedPreferences.getString("
// 5 seconds pause on splash page email",""));
Timer timer = new Timer(); logoutbtn =
timer.schedule(new TimerTask() { findViewById(R.id.logoutBtn);
@Override
public void run() { //make logout
if(isLoggedIn()){ logoutbtn.setOnClickListener(new
//Redirect to home page View.OnClickListener() {
intent = new @Override
Intent(context,HomeActivity.class); public void onClick(View view) {
startActivity(intent); // Redirect back to login
finish(); page
}else{ logout();
//Redirect to Login Page intent = new
intent = new Intent(context,LoginActivity.class);
Intent(context,LoginActivity.class); //remove all previous stack
startActivity(intent); activities
finish();
}
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_T
}
OP);
},5000);
startActivity(intent);
}
finish();
public void init() {
}
context = this;
});
sharedPreferences =
}
context.getSharedPreferences(SHARED_PREF_NAME
}
,MODE_PRIVATE);
}
} SignupActivity
package com.koiwai.loginsingup;
HomeActivity
import
package com.koiwai.loginsingup;
androidx.appcompat.app.AppCompatActivity;
import
import android.content.Intent;
androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.content.Intent;
import android.view.View;
import android.os.Bundle;
import android.widget.Button;
import android.view.View;
import android.widget.EditText;
import android.widget.Button;
import android.widget.TextView;
import android.widget.TextView;
import android.widget.Toast;
public class HomeActivity extends
import
MainActivity {
com.loopj.android.http.JsonHttpResponseHandle
r;
TextView nameTv;
import com.loopj.android.http.RequestParams;
TextView emailTv;
Button logoutbtn;
import org.json.JSONException;
import org.json.JSONObject;
@Override
protected void onCreate(Bundle
import cz.msebera.android.httpclient.Header;
savedInstanceState) {
super.onCreate(savedInstanceState);
public class SignupActivity extends
MainActivity {
getSupportActionBar().setTitle("Home");
context = this; EditText nameEt,emailEt,passwordEt;
init(); Button signupBtn;
TextView LoginNowTv;
@Override
protected void onCreate(Bundle //all inputs are validated now
savedInstanceState) { perform login request
super.onCreate(savedInstanceState); RequestParams params = new
RequestParams();
getSupportActionBar().setTitle("Registration" params.add("type","signup");
); params.add("name",name);
params.add("email",email);
params.add("password",password);
getSupportActionBar().setDisplayHomeAsUpEnabl
ed(true);
context = this; System.out.println("-------------------------
init(); ");
System.out.println(params);
WebReq.post(context, "api.php",
setContentView(R.layout.activity_signup);
params, new
getViews();
SignupActivity.ResponseHandler());
}
}
public void getViews() {
nameEt = findViewById(R.id.nameEt);
private class ResponseHandler extends
emailEt = findViewById(R.id.emailEt);
JsonHttpResponseHandler {
passwordEt =
@Override
findViewById(R.id.passwordEt);
public void onStart() {
signupBtn =
super.onStart();
findViewById(R.id.SignupBtn);
}
LoginNowTv =
findViewById(R.id.LoginNowTv);
@Override
signupBtn.setOnClickListener(new
public void onSuccess(int statusCode,
View.OnClickListener() {
Header[] headers, JSONObject response) {
@Override
super.onSuccess(statusCode,
public void onClick(View view) {
headers, response);
signupValidation();
Log.d("response
}
",response.toString()+" ");
});
try {
LoginNowTv.setOnClickListener(new
if
View.OnClickListener() {
(response.getBoolean("error")){
@Override
// failed to login
public void onClick(View view) {
finish();
} Toast.makeText(context,response.getString("me
}); ssage"),Toast.LENGTH_SHORT).show();
} }else{
// successfully logged
private void signupValidation() { in
name = nameEt.getText().toString(); JSONObject user =
email = emailEt.getText().toString(); response.getJSONObject("user");
password = //save login values
passwordEt.getText().toString();
sharedPrefEditor.putBoolean("login",true);
if (name.length()<3){
Toast.makeText(context,"Name at sharedPrefEditor.putString("id",user.getStrin
least 3 g("id"));
characters.",Toast.LENGTH_SHORT).show();
return;
sharedPrefEditor.putString("name",user.getStr
}
ing("name"));
if (email.length()==0){
Toast.makeText(context,"Invalid
Email Address",Toast.LENGTH_SHORT).show(); sharedPrefEditor.putString("email",user.getSt
return; ring("email"));
} sharedPrefEditor.apply();
if (isEmailValid(email)==false){
Toast.makeText(context,"Invalid sharedPrefEditor.commit();
Email Address",Toast.LENGTH_SHORT).show();
return; //Move to home activity
} intent = new
Intent(context,HomeActivity.class);
if (password.length()<5){
Toast.makeText(context,"Minimum intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_T
password length should be 5 OP);
characters.",Toast.LENGTH_SHORT).show(); startActivity(intent);
return; finish();
} }
} catch (JSONException e) {
e.printStackTrace(); loginBtn =
} findViewById(R.id.loginBtn);
} loginBtn.setOnClickListener(new
View.OnClickListener() {
@Override @Override
public void onFailure(int statusCode, public void onClick(View view) {
Header[] headers, String responseString, loginValidation();
Throwable throwable) { }
super.onFailure(statusCode, });
headers, responseString, throwable); signupNowTv.setOnClickListener(new
} View.OnClickListener() {
@Override
@Override public void onClick(View view) {
public void onFinish() { intent = new
super.onFinish(); Intent(context,SignupActivity.class);
} startActivity(intent);
} }
} });
}

private void loginValidation() {


LoginActivity email = emailEt.getText().toString();
password =
package com.koiwai.loginsingup;
passwordEt.getText().toString();
import
if (email.length()==0){
androidx.appcompat.app.AppCompatActivity;
Toast.makeText(context,"Invalid
Email Address",Toast.LENGTH_SHORT).show();
import android.content.Intent;
return;
import android.os.Bundle;
}
import android.util.Log;
if (isEmailValid(email)==false){
import android.view.View;
Toast.makeText(context,"Invalid
import android.widget.Button;
Email Address",Toast.LENGTH_SHORT).show();
import android.widget.EditText;
return;
import android.widget.TextView;
}
import android.widget.Toast;
if (password.length()<5){
import
Toast.makeText(context,"Minimum
com.loopj.android.http.JsonHttpResponseHandle
password length should be 5
r;
characters.",Toast.LENGTH_SHORT).show();
import com.loopj.android.http.RequestParams;
return;
}
import org.json.JSONException;
import org.json.JSONObject;
//all inputs are validated now
perform login request
import cz.msebera.android.httpclient.Header;
RequestParams params = new
RequestParams();
public class LoginActivity extends
params.add("type","login");
MainActivity {
params.add("email",email);
params.add("password",password);
EditText emailEt,passwordEt;
Button loginBtn;
TextView signupNowTv; System.out.println("-------------------------
String email,password; ");
System.out.println(params);
@Override WebReq.post(context, "api.php",
protected void onCreate(Bundle params, new LoginActivity.ResponseHandler());
savedInstanceState) { }
super.onCreate(savedInstanceState);
context=this; public void init() {
context =this;
sharedPreferences =
setContentView(R.layout.activity_login);
getSharedPreferences(SHARED_PREF_NAME,MODE_P
init();
RIVATE);
getViews();
sharedPrefEditor =
}
sharedPreferences.edit();
private void getViews() {
}
emailEt = findViewById(R.id.emailEt);
signupNowTv =
private class ResponseHandler extends
findViewById(R.id.signupNowTv);
JsonHttpResponseHandler {
passwordEt =
@Override
findViewById(R.id.passwordEt);
public void onStart() {
super.onStart(); xmlns:android="http://schemas.android.com/apk
} /res/android"

@Override xmlns:app="http://schemas.android.com/apk/res
public void onSuccess(int statusCode, -auto"
Header[] headers, JSONObject response) {
super.onSuccess(statusCode,
xmlns:tools="http://schemas.android.com/tools
headers, response);
"
Log.d("response
android:layout_width="match_parent"
",response.toString()+" ");
android:layout_height="match_parent"
try {
tools:context=".MainActivity">
if
(response.getBoolean("error")){
<TextView
// failed to login
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Toast.makeText(context,response.getString("me android:text="Hello World!"
ssage"),Toast.LENGTH_SHORT).show();
}else{
app:layout_constraintBottom_toBottomOf="paren
// successfully logged
t"
in
JSONObject user =
response.getJSONObject("user"); app:layout_constraintLeft_toLeftOf="parent"
//save login values
app:layout_constraintRight_toRightOf="parent"
sharedPrefEditor.putBoolean("login",true);
app:layout_constraintTop_toTopOf="parent" />
sharedPrefEditor.putString("id",user.getStrin
g("id")); </androidx.constraintlayout.widget.Constraint
Layout>
sharedPrefEditor.putString("name",user.getStr
ing("name")); SplashActivity
sharedPrefEditor.putString("email",user.getSt <?xml version="1.0" encoding="utf-8"?>
ring("email")); <RelativeLayout
sharedPrefEditor.apply(); xmlns:android="http://schemas.android.com/apk
/res/android"
sharedPrefEditor.commit();
xmlns:app="http://schemas.android.com/apk/res
//Move to home activity -auto"
intent = new
Intent(context,HomeActivity.class); xmlns:tools="http://schemas.android.com/tools
startActivity(intent); "
finish(); android:layout_width="match_parent"
} android:layout_height="match_parent"
} catch (JSONException e) { tools:context=".SplashActivity">
e.printStackTrace();
} <ProgressBar
} android:id="@+id/mPb"

@Override android:layout_centerHorizontal="true"
public void onFailure(int statusCode, android:layout_centerVertical="true"
Header[] headers, String responseString, android:layout_width="wrap_content"
Throwable throwable) { android:layout_height="wrap_content"
super.onFailure(statusCode, />
headers, responseString, throwable); <TextView
} android:text="@string/app_name"
android:gravity="center_horizontal"
@Override android:layout_below="@+id/mPb"
public void onFinish() { android:textSize="22dp"
super.onFinish(); android:layout_width="match_parent"
} android:layout_height="wrap_content"
} />
}
</RelativeLayout>
MainActivity
HomeActivity
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintL <?xml version="1.0" encoding="utf-8"?>
ayout <RelativeLayout
xmlns:android="http://schemas.android.com/apk android:textSize="20dp"
/res/android" android:textColor="@color/white"
android:layout_width="wrap_content"
xmlns:app="http://schemas.android.com/apk/res android:layout_height="wrap_content"
-auto" />
<EditText
android:id="@+id/nameEt"
xmlns:tools="http://schemas.android.com/tools
android:layout_below="@id/titleTv"
"
android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_centerHorizontal="true"
tools:context=".HomeActivity"> android:ems="11"
<TextView android:background="@color/white"
android:id="@+id/nameTv" android:padding="8dp"
android:text="Name" android:layout_marginTop="10dp"
android:textSize="22dp" android:layout_marginBottom="10dp"
android:textStyle="bold" android:hint="Name"
android:gravity="center_horizontal" android:inputType="text"
android:layout_centerVertical="true" android:layout_width="wrap_content"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_height="wrap_content" />
/> <EditText
<TextView android:id="@+id/emailEt"
android:id="@+id/emailTv" android:layout_below="@id/nameEt"
android:layout_below="@id/nameTv"
android:text="[email protected]" android:layout_centerHorizontal="true"
android:textSize="22dp" android:ems="11"
android:gravity="center_horizontal" android:background="@color/white"
android:layout_centerVertical="true" android:padding="8dp"
android:layout_width="match_parent" android:hint="Email"
android:layout_height="wrap_content" android:layout_marginBottom="10dp"
/> android:inputType="textEmailAddress"
<Button android:layout_width="wrap_content"
android:id="@+id/logoutBtn" android:layout_height="wrap_content"
android:text="Logout" />
android:textAllCaps="false" <EditText
android:background="#fa0e3d" android:id="@+id/passwordEt"
android:textColor="#FFFFFF" android:layout_below="@id/emailEt"
android:layout_marginTop="40dp"
android:layout_below="@id/emailTv" android:layout_centerHorizontal="true"
android:ems="11"
android:layout_centerHorizontal="true" android:background="@color/white"
android:layout_width="wrap_content" android:padding="8dp"
android:layout_height="wrap_content" android:hint="Password"
/> android:inputType="numberPassword"
android:layout_width="wrap_content"
</RelativeLayout> android:layout_height="wrap_content"
/>
SignupActivity <Button
android:id="@+id/SignupBtn"
<?xml version="1.0" encoding="utf-8"?> android:text="Signup"
<RelativeLayout android:textAllCaps="false"
xmlns:android="http://schemas.android.com/apk android:layout_marginTop="15dp"
/res/android"
android:layout_centerHorizontal="true"
xmlns:app="http://schemas.android.com/apk/res android:background="@color/white"
-auto"
android:textColor="@color/colorPrimary"
xmlns:tools="http://schemas.android.com/tools android:layout_below="@id/passwordEt"
" android:layout_width="wrap_content"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_height="match_parent" />
tools:context=".SignupActivity"> <TextView
android:id="@+id/LoginNowTv"
<TextView android:gravity="right"
android:id="@+id/titleTv" android:textColor="@color/white"
android:padding="5dp"
android:layout_below="@id/SignupBtn"
android:layout_centerHorizontal="true" android:layout_marginTop="20dp"
android:layout_marginTop="120dp" android:text="Already have an
android:text="Signup" acccount ? Login ?"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
/> />
</RelativeLayout> <EditText
android:id="@+id/passwordEt"
android:layout_below="@id/emailEt"
LoginActivity
android:layout_centerHorizontal="true"
<?xml version="1.0" encoding="utf-8"?> android:ems="11"
<RelativeLayout android:hint="Password"
xmlns:android="http://schemas.android.com/apk android:inputType="number"
/res/android" android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
xmlns:app="http://schemas.android.com/apk/res
<Button
-auto"
android:id="@+id/loginBtn"
android:text="Login"
xmlns:tools="http://schemas.android.com/tools android:layout_marginTop="15dp"
"
android:layout_width="match_parent"
android:layout_centerHorizontal="true"
android:layout_height="match_parent"
android:background="#fa0e3d"
tools:context=".LoginActivity">
android:textColor="#FFFFFF"
android:layout_below="@id/passwordEt"
<TextView
android:layout_width="wrap_content"
android:id="@+id/titleTv"
android:layout_height="wrap_content"
/>
android:layout_centerHorizontal="true" <TextView
android:layout_marginTop="120dp" android:id="@+id/signupNowTv"
android:text="Login" android:gravity="right"
android:layout_width="wrap_content" android:textColor="#fa0e5d"
android:layout_height="wrap_content" android:padding="5dp"
/> android:layout_below="@id/loginBtn"
<EditText android:layout_marginTop="20dp"
android:id="@+id/emailEt" android:text="Don't have an
android:layout_below="@id/titleTv" acccount ? Signup Now ?"
android:layout_width="match_parent"
android:layout_centerHorizontal="true" android:layout_height="wrap_content"
android:ems="11" />
android:hint="Email"
android:inputType="textEmailAddress" </RelativeLayout>

You might also like