For Size:
Add Dependencies app/Gradle/build.gradle −
you add Dependencis for SSP/SDP
dependencies {
implementation libs.appcompat
implementation libs.material
implementation libs.activity
implementation libs.constraintlayout
testImplementation libs.junit
androidTestImplementation libs.ext.junit
androidTestImplementation libs.espresso.core
implementation 'com.intuit.sdp:sdp-android:1.1.1'
implementation 'com.intuit.ssp:ssp-android:1.1.1' //add Library
}
TextView:
For textview follow below formate −
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoSizeMaxTextSize="@dimen/_100sdp"
android:autoSizeMinTextSize="@dimen/_1sdp"
android:autoSizeStepGranularity="2sp"
android:autoSizeTextType="uniform"
android:text="Text here" />
ImageView:
Step 01 -
Different sizes for 1image go to. Create Resource folder /res/new/Android Resource Directory/Resourse Type(Drawable)/Available qualifiers (Density) −
then create drawable-mdpi,drawable-hdpi,drawable-xhdpi etc.
and For ImageView follow below formate −
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/header"
android:layout_margin="@dimen/_10sdp"
android:scaleType="fitCenter"
android:src="@drawable/image" />
LinearLayout, RelativeLayout :
for LinearLayout, RelativeLayout follow below formate
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#D5D4D4"
android:padding="@dimen/_10sdp"
tools:context=".MainActivity">
<androidx.cardview.widget.CardView
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="#ffffff"
app:cardCornerRadius="@dimen/_5sdp"
app:cardElevation="@dimen/_10sdp"
app:cardUseCompatPadding="true"
tools:ignore="MissingConstraints">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:layout_width="@dimen/_30sdp"
android:layout_height="@dimen/_30sdp"
android:padding="@dimen/_5sdp"
android:scaleType="centerCrop"
android:src="@drawable/man_icon" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoSizeMaxTextSize="@dimen/_100sdp"
android:autoSizeMinTextSize="@dimen/_1sdp"
android:autoSizeStepGranularity="2sp"
android:autoSizeTextType="uniform"
android:text="Text here" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/header"
android:layout_margin="@dimen/_10sdp"
android:scaleType="fitCenter"
android:src="@drawable/image" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_margin="@dimen/_10sdp"
android:padding="@dimen/_5sdp"
android:text="Button" />
</RelativeLayout>
XML -
Create Different sizes XML. go to. Create Resource folder /res/new/Android Resource Directory/Resourse Type(Layout)/Available qualifiers (Size) −
then create different size xml like small, normal, large etc. Like below-