Android Dev Notes
Android Dev Notes
Android Dev Notes
XML syntax
Here the linear layout view has a opening tag but no closing tag.
Also, we have two xml elements in the linear layout view known as children xml with parent as linear
layout view.
The reason being It is not closed at the time when it was opened is we could not know the no of
children it is having.
Here src is the location of the source from where you want to display the image
Example:-
Some child view attributes relative to the parent (placing view relative to the parent)
Four attributes will help you to place child view any desiered position
Padding and margin:-
padding
margin
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:contentDescription="@string/image_1"
app:srcCompat="@drawable/androidparty"
/>
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Happy_birthday"
android:padding="20dp"
android:fontFamily="sans-serif-light"
android:textColor="@android:color/white"
android:textSize="32sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/from_devansh"
android:fontFamily="sans-serif-light"
android:textColor="@android:color/white"
android:textSize="32sp"
android:padding="20dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
App developed using the above code.