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:
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.
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:
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.
Top comments (0)