How to show introscreens in android app when app is opened first time - SpartaCode

SpartaCode

Make your development faster and easier !

How to show introscreens in android app when app is opened first time



To download app click on : Check out App


Custom In-App intro guide screens for Android :

Main idea behind in app intro guide screen is to make activity background transparent with some alpha and customizing look as you want.


Step 1 : Download Layout file : 


activity_introscreen.xml


Step 2: Edit your Manifest.xml file :


  <activity android:name=".IntroScreenActivity"

            android:theme="@style/Theme.Transparent"/>



Step 3 : Add code in res - styles.xml file


 <style name="Theme.Transparent" parent="Theme.AppCompat.Light.NoActionBar">

        <item name="android:windowIsTranslucent">true</item>

        <item name="android:statusBarColor">@android:color/transparent</item>

        <item name="android:windowBackground">@android:color/transparent</item>

  </style>


We are done with setting up introscreen you can run and see output and add which ever design you like.

You can finish introscreen activity once user clicks on it.

To make it more Cool :

You can add fade out animation on click of introscreen as follows :

Step 1: Create Animation file in anim package :fade_in.xml


<?xml version="1.0" encoding="utf-8"?>

<alpha xmlns:android="http://schemas.android.com/apk/res/android"

           android:interpolator="@android:anim/accelerate_interpolator"

           android:fromAlpha="0.0" android:toAlpha="1.0"



           android:duration="500" />


Step 2: Create Animation file for closing effect : fade_out.xml


<?xml version="1.0" encoding="utf-8"?>

<alpha xmlns:android="http://schemas.android.com/apk/res/android"

           android:interpolator="@android:anim/accelerate_interpolator"

           android:fromAlpha="1.0" android:toAlpha="0.0"

           android:fillAfter="true"



           android:duration="500" />



Step 3: Add this code when starting your introscreen activity :


Intent i = new Intent(this, IntroScreenActivity.class);
startActivity(i);
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);



If you want your introscreen to be only launched first time user opens app  you can use sharedPreference to store app opened status.

Download SharedPreference Util file :


SharedPreference.java

Copy paste code into your first homescreen Activity :


        SharedPreference spre=new SharedPreference(getApplicationContext());
        String show=spref.getData("IntroShown");
        if(show==null){
            Intent intent=new Intent(getApplicationContext(),IntroScreenActivity.class);
            startActivity(intent);
        }
        spref.setData("IntroShown","Yes");



Thank you
Share and Comment





No comments:

Post a Comment

Get Amazing Traffic to your Site

Traffic Exchange

Post Bottom Ad

Responsive Ads Here