Android Build Intro Slider Using ViewPager

build intro slider using viewpager

Android Build Intro Slider Viewpager .Hello Friends, How are you all. In this tutorial we are going to build intro slider using viewpager. Intro slider or Welcome screen is the best way to show main features of  your app. In our Intro Slider user user can swipe through few slides before getting into app.

To demonstrate, we will create a simple app that contains few intro slides with next and back navigation. The user can navigate through each slide using swipe gesture or using the next button. So lets start coding.

Demo

Screen Shot (Intro Slider using ViewPager)

how to build intro slider for android app

Creating New Project

  • Create a new project in Android Studio File–>New–>New Project.
  • Enter Application Name, Package Name, Select Empty Activity and click on finish.

Change Theme

  • Go to App–>values–>style.xml and change style of AppTheme to NoActionBar

Add ViewPager and Navigation Buttons

  • Now we will add ViewPager and Navigation Buttons to our Main Layout.
  • ViewPager is view which allows users to swipe left and right through pages of data.
  • Open activity_main.xml and in this layout we will take ViewPager inside of LinerLayout and we will also add Back and Next Button to navigate between slides.
  • Code for activity_main.xml.

Create Slide Layout

  • Now we will create slide layout.
  • Create one slide.xml file inside Layout folder.
  • This layout will represent our slide.
  • In this layout we will take one ImageView for image and two TextView, one for Slide title and another one for slide description. All these items we will take under LinerLayout.
  • Code for slide.xml.

our design part is completed.

Create Adapter for ViewPager

  • Create a new java class named SlideAdapter.java which will be adapter for viewpager.
  • The class should Extend PageAdapter.
  • Add required methods.
  • In this adapter we will define list of Images, Title, Description and Slide Colors which we will use in our app.
  • In this adapter we need to add two more important methods instantiateItem() and destroyItem().
  • Code for SlideAdapter.java

Instantiate ViewPager and Adapter

  • Open MainActivity.java and instantiate viewpager and adapter.
  • we will also use some HTML tricks to show slider dots.
  • and by using OnPageListener method we will control our navigation buttons which will help us to navigate through our slides.
  • So here is final codes for MainActivity.java

Now run your project and you will have fantastic Intro Slider for your app.

Download Complete Project

Android Build Intro Slider Using ViewPager Complete Project

Subscribe To Our YouTube Channel

 

Like Us On Facebook

 

Other Tutorials-

RECENT POST

Leave a Reply

Your email address will not be published. Required fields are marked *