You are on page 1of 8

GREEN UNIVERSITY OF BANGLADESH

Department of Computer Science & Engineering


(LAB REPORT - 01)

COURSE TITEL: Mobile Application Development Lab

COURSE CODE: CSE 402

Submitted To
MR. AMIT MANDAL
Lecturer
Department of CSE

Submitted By
Mahmuda Akter
ID: 181002013
Section: 181_DA
Department of CSE

Date of Submission: 03/03/2021


Report Name: An application that uses images and various colours.

Resources: Android Studio.

Objective: To design an application that displays an image and various colours


while clicking thebutton.

XML File:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayoutxmlns:android="http://schem
as.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">

<Button
android:id="@+id/b4"
android:layout_width="335dp"
android:layout_height="50dp"
android:backgroundTint="#E2E5DE"
android:text="OFF"
android:textColor=
android:textSize="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.215"/>

<Button
android:id="@+id/b1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#E2E5DE"
android:text="GREEN"
android:textColor="@color/black"
android:textSize="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.094"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.571"/>
<TextView
android:id="@+id/textView"
android:layout_width="293dp"
android:layout_height="36dp"
android:text="GUI Components"
android:textColor="#03A9F4"
android:textSize="30dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.677"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.102"/>

<Button
android:id="@+id/b2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#E2E5DE"
android:text="RED"
android:textColor=
android:textSize="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.51"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.571"/>

<TextView
android:id="@+id/t1"
android:layout_width="301dp"
android:layout_height="19dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.409"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.485"/>

<Button
android:id="@+id/b3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#E2E5DE"
android:text="BLUE"
android:textColor="@color/black"
android:textSize="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.882"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.571"/>

<TextView
android:id="@+id/textView3"
android:layout_width="167dp"
android:layout_height="23dp"
android:text="Color changeable fields"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.184"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.423"/>

<ImageView
android:id="@+id/imageView4"
android:layout_width="329dp"
android:layout_height="254dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.429"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.968"
app:srcCompat="@drawable/logo"/>

</androidx.constraintlayout.widget.ConstraintLayout>

Java File:
package com.example.guicomponents;

importandroidx.annotation.ColorLong;
importandroidx.appcompat.app.AppCompatActivity;

importandroid.graphics.Color;
importandroid.os.Bundle;
importandroid.view.View;
importandroid.widget.Button;
importandroid.widget.TextView;

publicclassMainActivityextends AppCompatActivity {

Button green, red, blue, off;

TextView color;

@Override
protectedvoidonCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
green = findViewById(R.id.b1);
red = findViewById(R.id.b2);
blue = findViewById(R.id.b3);
off = findViewById(R.id.b4);
color = findViewById(R.id.t1);

green.setOnClickListener(new View.OnClickListener() {
@Override
publicvoidonClick(View v) {

color.setBackgroundColor(Color.parseColor("#3CB043"));
green.setBackgroundColor(Color.parseColor("#3CB043"));
}
});

red.setOnClickListener(new View.OnClickListener() {
@Override
publicvoidonClick(View v) {

color.setBackgroundColor(Color.parseColor("#FF0000"));
green.setBackgroundColor(Color.parseColor("#40B3A5A5"));
green.setTextColor(Color.parseColor("#F5F5F5"));
red.setBackgroundColor(Color.parseColor("#FF0000"));
green.setEnabled(false);
}
});

blue.setOnClickListener(new View.OnClickListener() {
@Override
publicvoidonClick(View v) {

color.setBackgroundColor(Color.parseColor("#0000FF"));
green.setBackgroundColor(Color.parseColor("#40B3A5A5"));
red.setBackgroundColor(Color.parseColor("#40B3A5A5"));
blue.setBackgroundColor(Color.parseColor("#0000FF"));
green.setTextColor(Color.parseColor("#F5F5F5"));
red.setTextColor(Color.parseColor("#F5F5F5"));
green.setEnabled(false);
red.setEnabled(false);

}
});
off.setOnClickListener(new View.OnClickListener() {
@Override
publicvoidonClick(View v) {

color.setBackgroundColor(Color.parseColor("#FFFFFF"));
green.setBackgroundColor(Color.parseColor("#40B3A5A5"));
red.setBackgroundColor(Color.parseColor("#40B3A5A5"));
blue.setBackgroundColor(Color.parseColor("#40B3A5A5"));
green.setTextColor(Color.parseColor("#F5F5F5"));
red.setTextColor(Color.parseColor("#F5F5F5"));
blue.setTextColor(Color.parseColor("#F5F5F5"));
off.setTextColor(Color.parseColor("#F5F5F5"));
green.setEnabled(false);

red.setEnabled(false);

blue.setEnabled(false);

off.setEnabled(false);

}
});
}
}

Output:

Figure: 01 Figure: 02
Figure: 03 Figure: 04

Figure: 05

You might also like