In this tutorial, we will design a single screen for onboarding. you can develop a full three or four screen onboarding for your project.
Step 01 :
Create a new project in Android Studio from the File ⇒ New Project. As it prompts you to select the default activity, select Empty Activity and proceed.
Name your project as per your convenience and click finish.
Download this res.zip and add them to your project res folder. This file contains a few drawable images and font folder required for this app.
Now that we are done with the images, moving on to changing the text font. For this, we would need to add a custom font in our directory and asset folder as well. find custom fonts folder and asset folder and paste it under the java. Here is a reference image for custom fonts folder
For custom fonts folder

For asset folder

Step 02 :
Go to the build Gradle and do the needful changes as follows.
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' }
Open colors.xml located under res ⇒ values and add the below color values.
<?xml version="1.0" encoding="utf-8"?> <resources> <color name="colorPrimary">#333333</color> <color name="colorPrimaryDark">#242424</color> <color name="colorAccent">#D81B60</color> <color name="view_soft_grey_10">#1A000000</color> </resources>
Open strings.xml located under res ⇒ values and add the below values.
<resources> <string name="app_name">OnboardingSix</string> <string name="explore_new_species">Explore new species</string> <string name="onboardingsix_des">Science has identified some 2 million species of plants, animals and microbes on Earth, but scientists estimated there are millions more left to discover.</string> <string name="get_started">Get Started</string> </resources>
Open styles.xml located under res ⇒ values and add the below values.
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="windowNoTitle">true</item> <item name="android:windowFullscreen">true</item> </style> </resources>
Step 03 :
Now is the time for making the XML file. For this, Open activity_main.xml and paste the following code.
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:layout_width="match_parent" android:id="@+id/framelayout" android:layout_height="358dp"> <ImageView android:layout_width="match_parent" android:src="@drawable/onboardsiximage" android:scaleType="centerCrop" android:layout_height="match_parent"/> <LinearLayout android:layout_width="match_parent" android:background="#33000000" android:layout_height="24dp"/> </FrameLayout> <LinearLayout android:layout_width="match_parent" android:orientation="vertical" android:layout_gravity="center" android:layout_below="@+id/framelayout" android:layout_marginTop="17.9dp" android:gravity="center" android:layout_height="wrap_content"> <customfonts.MyTextView_LoraBold android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="30.7sp" android:textColor="#111010" android:lineSpacingExtra="8.3sp" android:layout_gravity="center" android:layout_marginLeft="25.6dp" android:layout_marginRight="25.6dp" android:gravity="center_horizontal" android:text="@string/explore_new_species" /> <customfonts.MyTextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="15.4sp" android:textColor="#3d3a3a" android:layout_marginBottom="12.1dp" android:layout_marginTop="15.6dp" android:layout_marginLeft="26.4dp" android:layout_marginRight="24.6dp" android:lineSpacingExtra="7.7sp" android:gravity="center_horizontal" android:text="@string/onboardingsix_des" android:layout_marginStart="26.4dp" android:layout_marginEnd="24.6dp" /> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="5dp" android:background="@drawable/bg_gradient_very_soft" android:layout_above="@+id/lay_bottom" android:layout_gravity="center" android:layout_marginRight="4.8dp" android:layout_marginEnd="4.8dp" /> <LinearLayout android:layout_width="match_parent" android:layout_height="56dp" android:orientation="horizontal" android:id="@+id/lay_bottom" android:layout_alignParentBottom="true"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginLeft="27.5dp" android:src="@drawable/paginationsix" android:layout_marginStart="27.5dp" /> <LinearLayout android:layout_width="match_parent" android:layout_gravity="end" android:gravity="end" android:layout_height="match_parent"> <customfonts.MyTextView_LatoBold android:layout_width="115dp" android:layout_height="match_parent" android:textSize="12sp" android:textColor="#ffffff" android:background="#9c39ab" android:lineSpacingExtra="1.5sp" android:gravity="center" android:text="@string/get_started" /> </LinearLayout> </LinearLayout> </RelativeLayout>
Now run the app and see the output, you will see the nice Onboarding single screen for your next android project.
So that’s all for this Onboarding single screen with Android studio code Tutorial. If you are having any confusion or queries please do comment. Thank You.