Android application that uses GUI components, font and colors - 01

Shwetha MK
22 Dec 202017:49

Summary

TLDRThis script offers a step-by-step guide to developing a basic Android application using Android Studio. It covers creating a new project, selecting an 'Empty Activity', setting the app name, package name, and choosing Java as the programming language. The tutorial then delves into designing the GUI with components like TextView and Buttons, adjusting font size and color. It also explains writing Java code for button actions, such as changing text size and color, and concludes with running the application on an emulator, showcasing the dynamic text resizing and color-changing features.

Takeaways

  • πŸ“± The script is a tutorial on developing an Android application using GUI components for font and color customization.
  • πŸ’» The process begins by opening Android Studio and creating a new project with an 'Empty Activity'.
  • πŸ” The user is guided to name the application, set a package name, and choose Java as the programming language.
  • πŸ“ The tutorial specifies selecting the minimum SDK version, which is API 16 for Android 4.1 Jelly Bean.
  • πŸ“ The script explains the structure of an Android application, highlighting the importance of Java files and XML files.
  • πŸ“ It details the anatomy of the 'activity_main.xml' file, where the layout design of the application is created.
  • πŸ”„ The tutorial demonstrates adding a TextView and two Buttons to the layout for changing font size and color.
  • πŸ–ŒοΈ The script describes how to modify the TextView content and the purpose of each button in the application.
  • πŸ”§ The Java file 'MainActivity.java' is where the functionality for the buttons is implemented, including changing font size and color.
  • πŸ”„ The 'setOnCLickListener' is used to define actions for button clicks, cycling through font sizes and colors.
  • πŸŽ₯ The final part of the script shows the execution of the application in an emulator, demonstrating the dynamic changes in font size and color.

Q & A

  • What is the first step in developing an Android application using Android Studio?

    -The first step is to open Android Studio and wait for it to load completely.

  • How do you create a new project in Android Studio?

    -You create a new project by clicking on the 'File' menu, then selecting 'New' and 'New Project'.

  • What types of activities can be selected when creating a new Android project?

    -Activities such as Basic Activity, Bottom Navigation Activity, Empty Activity, and Google AdMob Ads Activity can be selected.

  • What is the name of the application created in the script?

    -The application is named 'ShwApp'.

  • What is the package name automatically created for the 'ShwApp' project?

    -The package name created is 'com.example.shwap1'.

  • What programming language is used to develop the application in the script?

    -The application is developed using Java.

  • What is the minimum SDK version selected for the application in the script?

    -The minimum SDK version selected is API 16, which corresponds to Android 4.1 Jelly Bean.

  • What are the two main types of files involved in an Android application according to the script?

    -The two main types of files are Java files and XML files.

  • How does the script describe changing the font size of a TextView in an Android application?

    -The script describes using a button with an OnClickListener that increments a font size variable and applies the new size to the TextView.

  • How is the font color of a TextView changed in the application developed in the script?

    -The font color is changed by using another button with an OnClickListener that cycles through different color values stored in a variable.

  • What is the purpose of the 'setOnCLickListener' in the context of the Android application developed in the script?

    -The 'setOnCLickListener' is used to define actions that occur when a user clicks on the buttons, such as changing the font size or color of the TextView.

  • How does the application handle the maximum font size before resetting?

    -The application sets an initial font size of 30 and increases it by 5 with each button click until it reaches 50, at which point it resets back to 30.

  • What happens when the user clicks the 'Change Font Color' button in the application?

    -Clicking the 'Change Font Color' button cycles through a sequence of colors (red, green, blue, etc.) for the TextView based on the value of a variable that is incremented with each click.

  • How can the user execute the Android application program developed in the script?

    -The user can execute the program by selecting a device and clicking the 'Run' button in Android Studio, which opens an emulator to display the application.

Outlines

00:00

πŸ› οΈ Setting Up Android Studio and Creating a New Project

The script begins by introducing the process of developing an Android application using GUI components, font, and color customizations. It instructs the user to open Android Studio and wait for it to load. Once open, the user is guided to create a new project by selecting 'File' and then 'New Project'. The project setup includes choosing an activity type, in this case, an 'Empty Activity', and naming the application 'ShwApp'. The script also covers setting the package name, choosing the development language (Java in this instance), and selecting the minimum SDK version required for the app. The user is advised to wait for the project to build completely before proceeding.

05:00

πŸ“± Designing the User Interface with GUI Components

This paragraph delves into the design aspect of the Android application. It explains how to navigate the Android Studio interface to include GUI components such as a TextView and Buttons. The user is shown how to drag and drop a TextView onto the layout and how to modify its content. Additionally, it details the process of adding two buttons to the application, one for increasing font size and another for changing font color. The paragraph emphasizes the importance of the design layout and how to switch between code and design views in Android Studio.

10:02

✍️ Writing Java Code for GUI Interaction

The third paragraph focuses on writing the Java code that will handle the functionality of the GUI components. It starts by outlining the necessary package imports and the creation of a class named 'MainActivity'. The class extends the 'Activity' class and initializes variables for font size and color. The 'onCreate' method is discussed, which sets up the layout of the application. The paragraph then describes how to create objects for the TextView and Buttons, and how to set up 'OnClickListeners' for the buttons to change the font size and color when clicked. The code snippet provided demonstrates the logic for incrementing font size up to a maximum value before resetting it, and cycling through a predefined set of colors for the text.

15:02

🎬 Executing and Testing the Android Application

The final paragraph of the script describes the execution and testing process of the Android application. It instructs the user to select an emulator and run the application. The user is shown how the application will respond to button clicks, changing the font size up to a maximum and then resetting it, as well as cycling through different text colors. The paragraph concludes by demonstrating the successful execution of the program, with the text 'PEACE' dynamically changing its font size and color as the user interacts with the buttons.

Mindmap

Keywords

πŸ’‘Android Studio

Android Studio is the official integrated development environment (IDE) for Android app development, based on IntelliJ IDEA. It provides a range of tools for developers to design, code, debug, and test their applications. In the video's context, Android Studio is used to initiate the creation of a new Android application project, emphasizing its role as the foundational tool for app development.

πŸ’‘GUI Components

GUI stands for Graphical User Interface, and components refer to the visual elements that make up the interface, such as buttons, text fields, and labels. In the script, GUI components are essential for designing the user interface of the Android application, allowing users to interact with the app through visual elements like buttons to change font size and color.

πŸ’‘Font and Colors

Font refers to the typeface and size used in text, while colors pertain to the hues used in the graphical elements of a design. The video script discusses how to change these attributes within an Android app to customize the appearance of text. For instance, it explains how to increase the font size and change the font color through buttons, which are GUI components.

πŸ’‘New Project

In Android Studio, a 'New Project' is the starting point for creating an Android application. It involves setting up the initial configuration for the app, including the name, package name, and other preferences. The script describes the process of creating a new project named 'shw app' as an example of starting an Android application development.

πŸ’‘Activity

In Android app development, an 'Activity' represents a single screen with a user interface. The script mentions selecting an 'Empty Activity' during the project creation process, which is a basic template for starting an app without any predefined UI elements, allowing developers to build the interface from scratch.

πŸ’‘XML

XML, or Extensible Markup Language, is used in Android development to define the layout and UI elements of an application. The script refers to 'activity_main.xml', which is an XML file where the layout for the main screen of the app is designed, including the placement of a TextView and Buttons.

πŸ’‘Java

Java is a programming language used in Android development for writing the app's logic and functionality. The script specifies that the application will be developed using Java, and it outlines the process of writing Java code to handle button clicks and change the font size and color in the app.

πŸ’‘Minimum SDK

The 'Minimum SDK' version indicates the lowest version of the Android operating system that the app is compatible with. The script mentions setting the minimum SDK to API 16, which corresponds to Android 4.1 Jelly Bean, determining the app's accessibility to older Android devices.

πŸ’‘TextView

A 'TextView' is a GUI component in Android used to display text on the screen. In the script, a TextView is added to the app's layout to show the string 'peace', and its font size and color can be dynamically changed using buttons, demonstrating the app's interactive capabilities.

πŸ’‘Button

A 'Button' in Android is a GUI component that users can tap to trigger actions or events within the app. The script describes adding two buttons to the app's layout, one for changing the font size and another for changing the font color, showing how to assign functionality to UI elements.

Highlights

Introduction to developing the first Android application using GUI components, font, and colors in Android Studio.

Opening Android Studio and waiting for it to load to start a new project.

Creating a new project and selecting an 'Empty Activity' for the application.

Naming the application 'Shw App' and automatically generating the package name.

Choosing Java as the programming language for the Android application development.

Setting the minimum SDK to API 16, Android 4.1 Jelly Bean, for application compatibility.

Exploring the anatomy of an Android application with its folders and files.

Understanding the role of 'AndroidManifest.xml' and 'activity_main.xml' in the application structure.

Designing the application layout using 'activity_main.xml' to include GUI components.

Inserting a TextView and setting its content to 'PEACE' in the application interface.

Adding two buttons for changing font size and color within the application.

Customizing button names to 'Change Font Size' and 'Change Font Color' for clarity.

Writing Java code to handle button clicks and update TextView properties.

Using 'setOnCLickListener' to define actions for the 'Change Font Size' button.

Implementing logic to cycle through font sizes upon button clicks.

Using a switch statement to change the font color based on the button click count.

Resetting the font size and color to default values after reaching maximum values.

Executing the Android application to demonstrate the dynamic change of font size and color.

Closing remarks and acknowledgment of the completed Android application demonstration.

Transcripts

play00:00

the first android application program

play00:03

is develop an application that uses

play00:07

gui components font and colors

play00:10

i'll show how to develop this android

play00:14

application

play00:17

for this first we need to open the

play00:20

android studio

play00:24

wait for few minutes until this android

play00:28

studio window were opened

play00:34

in this android studio first we have to

play00:38

create a

play00:39

new project for that click on

play00:42

file menu in that select new

play00:45

and new project click on this new

play00:48

project an activity window is

play00:53

opened this activity window contains

play00:56

many activities like basic activities

play01:00

bottom navigation activity empty

play01:02

activity

play01:03

and google admob ads activity

play01:07

google map activity like this there are

play01:10

many different types of

play01:12

activities are they among these

play01:14

activities

play01:15

i'll select empty activity so

play01:18

click on this empty activity then click

play01:21

on

play01:22

next button

play01:25

and name window is opened and thus

play01:28

first we need to specify the name of the

play01:32

application i'll give the application

play01:35

name

play01:36

as shw app

play01:39

one okay so after this automatically the

play01:43

package name is created

play01:44

so the package name is

play01:49

com.example.shwap1

play01:52

if you want to store this application in

play01:54

a different location you can change this

play01:56

location

play01:57

otherwise you have to use this default

play02:00

location

play02:01

and the next one is the language so we

play02:04

can develop the

play02:05

android application using java language

play02:08

or kotlin language

play02:09

here i want to develop my application in

play02:12

java

play02:13

so i have selected java

play02:17

next one is minimum sdk which indicates

play02:20

minimum version of android that is

play02:23

required for our

play02:25

android application for the execution

play02:27

here

play02:28

minimum version that i have selected is

play02:30

api

play02:31

16 android 4.1 jdb

play02:35

next you just click on finish

play02:43

so now wait till the project gets

play02:46

completely

play02:47

built here it is still it is

play02:51

loading so you should wait till this

play02:53

project

play02:54

gets completely built

play02:59

just maximize this new project screen

play03:05

now in this window on left panel

play03:08

so we have see so many folders so

play03:11

like manifest folder right

play03:15

so which contains androidmanifest.xml

play03:19

file

play03:19

and java folder so this java folder

play03:22

which contains the

play03:23

java java files right and then resource

play03:27

which contains drawab drawable for

play03:30

folder

play03:31

and layout folder which contains

play03:33

activity main.xml

play03:35

and right so then like that so there are

play03:37

so many folders you can see on this

play03:40

left panel so this is the

play03:43

anatomy of your android application

play03:47

your android application contains two

play03:50

files

play03:50

one is java file another one is xml file

play03:54

see

play03:54

this java file which is actually stored

play03:57

in the folder

play03:58

java within that so we have a project

play04:01

name as

play04:04

com.example.shwf1

play04:05

under this where so this main

play04:07

activity.java file is

play04:09

get stored and another file so the other

play04:12

file is

play04:13

activity main dot xml file so this is

play04:16

the

play04:17

layout file this layout file which is

play04:20

stored under the directory

play04:26

stored under the directory layout so

play04:29

here this is

play04:30

activity main dot xml file

play04:34

in this activity main xml file

play04:37

we will do all our design part

play04:42

on right hand side corner you can see

play04:44

code split

play04:46

and design see so this is the design

play04:48

layout

play04:49

so if you want to just see only the

play04:51

design layout

play04:52

you just click on the design layout you

play04:55

can see the design layout

play04:56

along with this palette panel

play05:00

in case if you want to see that code

play05:02

activity main xml code

play05:04

and also the palette panel and also this

play05:07

design so you just click on split if you

play05:11

just want to see the code of this

play05:13

activity main.xml you just click on

play05:16

quote next i'll show

play05:20

how to include or how to embed that gui

play05:23

components

play05:24

and also how to change the font size and

play05:26

also

play05:27

font color so for that i just

play05:30

click on this design so here so i

play05:33

for this i'll just include our insert

play05:36

two buttons

play05:37

okay so one button it used to increase

play05:40

the font size

play05:41

okay another button which is used to

play05:44

change the font color of the

play05:46

text mean so first

play05:49

i want to insert a textview so

play05:52

i'll just select this textview

play05:55

okay so then i just drag and drop that

play05:59

textview okay so here if you want to

play06:02

change the content in the text view

play06:06

okay so you just click on this

play06:10

split see here and text wave is

play06:13

added right

play06:17

here a text weep is added see

play06:20

where so this text is which indicates

play06:23

the

play06:24

the text that should be displayed on our

play06:27

application i'll just change this text

play06:30

view or the

play06:31

message or the string that i want to be

play06:33

displayed on the

play06:36

application as free sc

play06:39

i'll just change it like this okay so

play06:42

now you can see it in the application

play06:46

i'll just maximize this

play06:49

okay just minimize this palette button

play06:52

or you just click on

play06:53

design see okay you can see pac

play06:57

here okay

play07:00

i'll just maximize this okay

play07:10

see pac is displayed here

play07:14

now i'll just minimize it to normal size

play07:18

next i want to add two buttons

play07:21

okay see initially

play07:24

you are the activity main xml which

play07:28

contains only the text view

play07:30

so now i want to insert two buttons to

play07:33

my

play07:33

application so for that click on design

play07:36

and here see here in the palette panel

play07:39

text

play07:39

buttons widget layouts are there you

play07:42

just click on buttons and then

play07:44

just to drag the button this is the

play07:47

first button

play07:48

and drag i want to use one more button

play07:50

so that is the

play07:51

second button okay so now

play07:59

now i want to change this button name so

play08:02

one button is used to change the font

play08:04

size

play08:04

another button is used to change the

play08:06

font

play08:07

color for that we just click on split

play08:12

right see here so button one

play08:15

so this is the button where its id is

play08:18

button here this is the name of this

play08:20

button is button only

play08:21

i'll just change this to

play08:26

change

play08:29

font size i want to use

play08:33

this button to change the font size

play08:36

next second button words id

play08:40

okay i want to use this button to change

play08:44

the

play08:44

color

play08:50

okay so now see here the button name is

play08:53

changed to change

play08:54

font size and also the change color

play08:59

next see this is the design part

play09:05

now the design part is over have

play09:08

included or inserted a textview

play09:10

and over its name as or the textview

play09:12

contains the string p-e-a-c-e

play09:15

and i have inserted two buttons the

play09:17

first button for changing the font size

play09:19

either its id is button only and the

play09:22

second button

play09:23

is used to change the color the of the

play09:26

string that is displayed in the

play09:28

text b now

play09:31

next we will move on to the java file

play09:34

here we need to write the code for

play09:37

the buttons and also the text field

play09:40

means what

play09:41

on clicking the button what should be

play09:43

the next action

play09:44

or on clicking the button first button

play09:46

what is the next action

play09:48

the next action should be that change

play09:50

the string that is displayed in the text

play09:52

field

play09:53

that change the font size of the string

play09:56

that is displayed in the text field

play09:58

what's the action when i click on the

play10:00

second button button too

play10:01

so that will change the text color that

play10:04

is displayed in the

play10:06

text beam next

play10:09

i will show how to write the java file

play10:12

so for that click on this activity

play10:15

main activity dot java file

play10:19

have already written a program i just

play10:21

copied that program to this

play10:23

java okay see

play10:27

here so initially so the first statement

play10:30

in your java file must be the package

play10:32

you already know the package name of our

play10:34

android application

play10:36

that is com.example.shwf1

play10:40

here i have imported many packages like

play10:43

activity packages

play10:44

graphics bundle bu button and also

play10:47

textview packages

play10:49

that are need required to develop our

play10:51

android application

play10:55

to create this android application so

play10:57

first

play10:58

create a class okay where the class name

play11:00

is main activity

play11:02

so that's why your java file name should

play11:04

be main activity dot

play11:06

java here if you have changed the name

play11:08

so this

play11:09

name is also changed so here the main

play11:12

your java file

play11:13

which extends the predefined class

play11:16

activity

play11:17

and here have taken two

play11:21

variables one is of type integer either

play11:24

one is of type

play11:25

float here the integer variable is

play11:28

choice that is ch it is initialized to 1

play11:32

and have taken one more variable font so

play11:34

it is initialized to

play11:36

the value 30. so here the choice

play11:39

variable is used to

play11:40

change the font color of the text that

play11:43

is displayed in the text view

play11:45

and this fourth variable is used to

play11:48

change the

play11:49

font size of the text that is displayed

play11:51

in the

play11:52

textview when we run the application

play11:56

so first this oncreate method is called

play11:59

automatically

play12:00

so this oncreate method which in turn

play12:03

called the

play12:04

setcontentview method so which actually

play12:06

create the

play12:07

layout for our application

play12:11

our application which contains one text

play12:13

feed and

play12:14

two buttons so that's why see here first

play12:17

you have to create the

play12:18

object for the text field and also the

play12:21

button here

play12:22

so t is an object of the class text wave

play12:26

and then i have created an object b1

play12:29

of the class button and also b2 for the

play12:33

class

play12:33

button right because here so this

play12:37

because now our application it has one

play12:40

text field

play12:40

and also two buttons see this t which

play12:43

refers to the

play12:44

text view of our application the button

play12:47

b1

play12:48

which refers to the button see here what

play12:50

is the button id

play12:52

button id is button itself see here now

play12:55

so b1 button so the button id is

play12:58

this button right so therefore b1 which

play13:01

refers to the

play13:02

button change font size button similarly

play13:05

i have created another object b2 which

play13:08

refers to the button

play13:09

where its id is button to see the button

play13:12

id

play13:12

is button2 so this is nothing but the

play13:15

button

play13:16

that is used to change the color so

play13:18

therefore

play13:19

so here in our application i have used

play13:22

one text sweep

play13:23

and two buttons b1 and b2

play13:27

next you are going to learn so what

play13:30

happens when i click on these

play13:32

buttons when i click on the button

play13:38

change font size button and i click on

play13:41

this change font size button

play13:43

so what i do it change the font size of

play13:45

the text

play13:46

that is displayed in the text view or if

play13:49

you click on the

play13:50

button change the color what do you do

play13:52

it just

play13:53

change the color of the text that is

play13:55

displayed in the

play13:57

text view so now

play14:00

i'll show the code java code see here

play14:03

set on click listener interface this is

play14:06

used

play14:06

see here when you click on the button

play14:09

one

play14:09

so that is change font size button so

play14:12

when you click on that

play14:14

button the font size will be changed so

play14:16

here

play14:17

have taken initial font size as 30 when

play14:20

you

play14:20

click on that font size button right it

play14:23

changes this font size button

play14:26

of the sorry it changes the font size of

play14:28

the text

play14:29

initially the font size is 30 next time

play14:32

it becomes 35

play14:33

because 5 is added to this variable font

play14:37

again you click on the same button font

play14:39

says that

play14:40

in again increase the font size to 40 45

play14:44

like that see when the font says is

play14:46

reached the

play14:48

value 50 means what when the font size

play14:50

of the text

play14:51

becomes 50 again it is reset to 30

play14:55

again if you click on the same button

play14:57

change font size button

play14:58

again so the font size will change to 35

play15:01

40

play15:01

45 50. when it reaches 50 again this

play15:05

font size will be reset to 30.

play15:08

similarly i have used one more button

play15:10

what is that change

play15:12

font color so here initial for that have

play15:15

chicken the variable

play15:16

ch is equal to one see here so again

play15:19

on the b2 button you just call set on

play15:22

click listener when i click on that

play15:24

button

play15:24

change font color right so if initial

play15:27

value for ch is one means initially the

play15:29

text color should be

play15:30

right again if we click on that see

play15:34

again so if ch is equal to one the font

play15:37

color should be

play15:37

red again cutter almost out of switch

play15:40

next ch will be incremented by

play15:42

one right means what again if you click

play15:44

on

play15:45

the same button change font color button

play15:48

so then the text ch value becomes to

play15:52

means what font color will be changed to

play15:54

green

play15:55

again the ch value is incremented by one

play15:58

means ch becomes three

play15:59

again if you click on the same button

play16:02

again ch value is

play16:03

three so therefore the third choice is

play16:06

the

play16:06

font color will be set to the blue color

play16:09

so like this if you again click on the

play16:12

same button the font color will change

play16:14

to see on

play16:14

again if you click on that button the

play16:16

font color is changed to yellow

play16:18

next magenta when the value reaches

play16:21

seven

play16:21

again the ch value reaches reset it to

play16:25

one means what if you again click on the

play16:28

same button

play16:29

again the falses will be changed to red

play16:31

again if you click on the same button

play16:33

green

play16:33

like that it goes on

play16:36

now i'll show how to execute this

play16:39

program

play16:40

okay so for that say here so

play16:43

you have to select the device here i

play16:46

have selected

play16:47

so this fixed the api 27 next

play16:50

so click on this run button so

play16:54

when i click on this run button okay

play16:59

an emulator would be opened see

play17:03

here an emulator is open when i click on

play17:06

this

play17:06

change font size button the font size of

play17:09

the text

play17:10

will be changed see when i reach its

play17:13

maximum size right this is size 50

play17:17

it is reset to the initial size

play17:20

30. next the other button is

play17:23

change the color of the text when i

play17:26

click on this button

play17:27

the color of the text peac will be

play17:30

changed

play17:30

see right like this the color of the

play17:34

text will be

play17:35

changed again it will be reset to the

play17:38

red

play17:38

color so like this we execute the

play17:41

android application program

play17:45

thank you

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
Android DevelopmentGUI ComponentsFont CustomizationColor ChangeApp TutorialJava ProgrammingAndroid StudioUser InterfaceMobile AppsProgramming Guide