Ad Code

Responsive Advertisement

Basic Android Program 13

Question 13: Write a program to create a login form for a social networking site.

Download hole Program / Project code, by clicking following link:

Name the file in which respective XML components can be added in Android Studio?

In Android Studio, the respective XML components can be added to the following files:
  1. Activity layout: The activity layout can be defined in an XML file located in the res/layout directory. The file name is usually activity_main.xml, where main can be replaced with any relevant name.
  2. Fragment layout: The fragment layout can be defined in an XML file located in the res/layout directory. The file name is usually fragment_main.xml, where main can be replaced with any relevant name.
  3. Menu: The menu can be defined in an XML file located in the res/menu directory. The file name is usually menu_main.xml, where main can be replaced with any relevant name.

  4. Dialog layout: The dialog layout can be defined in an XML file located in the res/layout directory. The file name is usually dialog_main.xml, where main can be replaced with any relevant name.
  5. Custom View: Custom views can be defined in an XML file located in the res/layout directory. The file name can be any relevant name.
Note that these are just a few examples of the types of files where XML components can be added in Android Studio. Depending on the requirements of your app, you may need to create additional XML files or modify the existing ones.


Programming Code:

Following code write in: MainActivity.java
package com.go2collage.practical_13;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

Following code write in: activity_main.xml
<?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"
android:orientation="vertical"
android:background="#495B8F"
android:padding="20dp">


<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="F A C E B O O K"
android:textAlignment="center"
android:layout_marginTop="40dp"
android:textSize="40sp"
android:textColor="@color/white"
tools:ignore="HardcodedText" />

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:background="@color/white"
android:fontFamily="monospace"
android:hint="Email or phone number"
android:padding="10dp"
android:textSize="22sp"
tools:ignore="Autofill,HardcodedText,TextFields,TextContrastCheck" />

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="@color/white"
android:fontFamily="monospace"
android:hint="Password"
android:padding="10dp"
android:textSize="22sp"
tools:ignore="Autofill,HardcodedText,TextFields,TextContrastCheck" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Forgot Password ??"
android:layout_marginTop="10dp"
android:textColor="@color/white"
android:textSize="18sp"
android:textAlignment="textEnd"
tools:ignore="HardcodedText" />

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="35dp"
android:background="@color/btn_color1"
android:padding="5dp"
android:text="Log In"
android:textSize="18sp"
tools:ignore="HardcodedText,TextContrastCheck" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Create New Account"
android:layout_marginTop="10dp"
android:textColor="@color/white"
android:padding="10dp"
android:textSize="20sp"
android:background="@color/btn_color2"
android:textAlignment="center"
tools:ignore="HardcodedText" />


<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:text="go2collage"
android:textAlignment="center"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="HardcodedText,TextContrastCheck" />

</LinearLayout>

Output:



Post a Comment

0 Comments

Ad Code

Responsive Advertisement