How to Create a Basic Intro Slider of an Android App?
Last Updated : 26 Jul, 2024
When we download any app and use that app for the very first time. Then we will get to see the intro slider inside our app. With the help of this slider, we educate our users on how they can use that app and it tells in detail about the app. In this article, we will take a look at the implementation of Intro Slider inside our app. Now, let's move towards the implementation of this feature in our app.
What we are going to build in this article?
We will be building a simple application in which we will be adding an intro slider that will tell about the different courses which are available on GeeksforGeeks. A sample GIF is given below to get an idea about what we are going to do in this article. Note that we are going to implement this project using the Java language.
Step by Step Implementation of Intro Slider
Step 1: Create a New Project
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Java as the programming language.
Step 2: Add dependency of Intro Slider in build.gradle file.
Navigate to the gradle scripts > build.gradle (app) file and add the below dependency to it in the dependencies section.
implementation 'com.github.AppIntro:AppIntro:6.0.0'
Now navigate to the Gradle Scripts > build.gradle file of (Project) and add below code inside the repositories section.
allprojects {
repositories {
// add below line in repositories section
maven { url 'https://jitpack.io' }
google()
jcenter()
}
}
Step 3: Create a new Java class that will display the slides for our slider
For creating a new java class navigate to the app > java > your app's package name > Right-click on it and click on New > Java class and name it as IntroSlider. After creating this class add the below code to it. Comments are added inside the code to understand the code in more detail.
Java import android.os.Bundle; import androidx.core.content.ContextCompat; import com.github.appintro.AppIntro; import com.github.appintro.AppIntroFragment; public class IntroSlider extends AppIntro { // we are calling on create method // to generate the view for our java file. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // below line is for adding the new slide to our app. // we are creating a new instance and inside that // we are adding the title, description, image and // background color for our slide. // below line is use for creating first slide addSlide(AppIntroFragment.newInstance("C++", "C++ Self Paced Course", R.drawable.gfgimage, ContextCompat.getColor(getApplicationContext(), R.color.purple_200))); // below line is for creating second slide. addSlide(AppIntroFragment.newInstance("DSA", "Data Structures and Algorithms", R.drawable.gfgimage, ContextCompat.getColor(getApplicationContext(), R.color.purple_200))); // below line is use to create third slide. addSlide(AppIntroFragment.newInstance("Java", "Java Self Paced Course", R.drawable.gfgimage, ContextCompat.getColor(getApplicationContext(), R.color.purple_200))); } }
Step 4: Working with the AndroidManifest.xml file
As we are creating a new activity for displaying our Intro Slider we are adding this activity to your AndroidManifest.xml file. Add the below lines to your AndroidManifest.xml file
<!--adding activity for our intro slider-->
<activity
android:name=".IntroSlider"
android:theme="@style/Theme.AppCompat.NoActionBar" />
Below is the complete code for the AndroidManifest.xml file.
XML <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.gtappdevelopers.firebaseapp"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.FirebaseApp"> <!--adding activity for our intro slider--> <activity android:name=".IntroSlider" android:theme="@style/Theme.AppCompat.NoActionBar" /> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
Step 5: Working with the MainActivity.java file
Go to the MainActivity.java file and refer to the following code. Below is the code for the MainActivity.java file.
Java import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.widget.GridView; import android.widget.Toast; import java.util.ArrayList; import java.util.List; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent i =new Intent(getApplicationContext(),IntroSlider.class); startActivity(i); } }
After adding this code now run your app and see the output of the app.
Output:
Similar Reads
How to Create a Custom Intro Slider of an Android App?
Intro Slider in many apps is mostly used to educate the users about the app, the features of the app, and the services that our app will provide to us. In this article, we will take a look at the implementation of Custom Intro Slider in our app. What we are going to build in this Article? We will be
8 min read
How to Create a Basic Widget of an Android App?
Widgets are the micro-version of the application that consists of some functionality of the application that is displayed only on the Home Screens or the Lock Screen. For example, we see Weather, Time, and Google Search Bars on the Home Screen, and FaceLock, and FingerprintLock on the Lock Screen, w
5 min read
Create Custom Intro Slider of an Android App with Kotlin
IntroSlider is seen in many android applications to display the introduction of the different screens within our application. This intro slider will display information about different features within the android application. In this article, we will take a look at How to Create a Custom Intro Slide
8 min read
How to Create a Unlock Slide-Bar in Android?
A SeekBar is an extension of ProgressBar that adds a draggable thumb. The user can touch the thumb and drag left or right to set the current progress level or use the arrow keys. SeekBar is a useful user interface element in Android that allows the selection of integer values using a natural user in
5 min read
How to Create a Dice Roller App in Android?
A dice roller application is a simple application that generates a random number between 1 and a specified maximum number, simulating the roll of a dice. The application is typically used by gamers or anyone who needs to roll a die but doesn't have physical dice available. To create the app, you nee
2 min read
How to Create a Wallpaper App in Android Studio?
Almost all Android devices are having a wallpaper set on their home screen. For setting this wallpaper to the screen many Android devices provides a Wallpaper Application where we can browse different types of wallpapers based on various categories. In this article we will look at, building a simila
15+ min read
How to Add Widget of an Android Application?
It's known that many of the android apps that have installed on the phone contain widgets. The most common examples are the Calendar and the Clock widget. So what are these Widgets? Widgets are just a mini-app that lives on the home screen and apart from small launcher icons that normally appear on
8 min read
How to Draw Over Other Apps in Android?
Sometimes we require our app to show some content on the main screen irrespective of the app running in the foreground, this process is known as drawing over other apps. There are many apps that use this functionality to provide maximum features with minimum screen coverage. This also enables the us
7 min read
How to Create Buttons Inside a Widget in Android?
PrerequisitesHow to Create a Basic Widget of an Android App?How to Create a Dynamic Widget of an Android App?A Widget is a mini version of an Application, that provides a ground for the user to navigate through it or use its features from the Home Screen or Lock Screen. Widgets contain elements acco
4 min read
How to Create an Animated Splash Screen in Android?
Prerequisites: How to Create a Splash Screen in Android using Kotlin? Android Splash Screen is the first screen visible to the user when the applicationâs launched. Splash Screen is the user's first experience with the application that's why it is considered to be one of the most vital screens in th
4 min read