DEV Community

Cover image for Views and it's types in Android {Android Development} | Day 2πŸ”₯πŸš€
Atharva Shirdhankar
Atharva Shirdhankar

Posted on

4

Views and it's types in Android {Android Development} | Day 2πŸ”₯πŸš€

In last blog(here)I talked about prerequisites ,tools and tech stack/Programming language we use for Android Development. And how XML help us in structuring and designing components and how Java/Kotlin/C++ is used for Logic
for our Android app.

In Android Development ,the first thing we need to learn is something called Views.
View is a basic building block of UI (User Interface) in android.
And using the series of views we build our Application UI
At start we will have a look over 3 basic views πŸ‘‡

1.1 TextView πŸ‘‡
The first and commonly used view is "TextView".
➑️ TextView is the most widely used view used to show pre-defined text on display screen.
Snippet:
Alt Text

1.2 Few TextView attributesπŸ‘‡
i . android:text
➑️ Text to display.
ii . android:textColor
➑️ Text color.
iii . android:textStyle
➑️ Style (normal, bold, italic, bold|italic) for the text.
iv . android:fontFamily
➑️ Font family for the text.

Read more about πŸ‘‰ TextView

2.1 ImageView πŸ‘‡
➑️ The second commonly used view is "ImageView".
ImageView are used in Android application to place an image in the view.ImageView is used to show any picture on the user interface.

Snippet:
Alt Text

2.2 Few ImageView attributes
i . android:src
➑️ Sets a drawable as the content for this ImageView.
ii. android:cropToPadding
➑️ If true, the image will be cropped to fit within its padding.
iii. android:tint
➑️ The tinting color for the image.

Note for ImageView πŸ‘‡
Any image that we want to display in the app should be placed under the drawable folder. This folder can be found under
app β†’ res β†’ drawable.
To insert an image, simply copy the image and then right click on drawable β†’ Paste.

Read more about πŸ‘‰ ImageView

3.1 Button
A user interface element the user can tap or click to perform an action.
Snippet:
Alt Text

About the Button πŸ‘‡
We use Button to trigger the method we wrote in Java/Kotlin/C++ using "android:onClick" attribute of button view.

Read more about πŸ‘‰ Button

Resources
Online XML visualizer for practicing Purpose.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay