• We just launched and are currently in beta. Join us as we build and grow the community.

Android - Simple Splash Screen

Dikzak

Adaptive Defense Specialist
D Rep
0
0
0
Rep
0
D Vouches
0
0
0
Vouches
0
Posts
142
Likes
30
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 100 XP
Operating System

Android

In this tutorial we will try to create a Simple Splash Screen Using Android. Android is most commonly comes installed on a variety of smartphones and tablets, and even in TV. Android is an open source so that developer find it easy to develop and expand new features. So let's do the coding...

Getting Started:

First you will have to download & install the Android Development IDE (Android Studio or Eclipse). Android Studio is an open source development feel free to develop your things.

Here's the link for the Android Studio https://developer.android.com/studio/index.html.

Layout Design

We will now create the design for the application, first locate the activity_main.xml and click text to view the script. Then copy and paste the code below.
  1. <?

    xml version=

    "1.0"

    encoding=

    "utf-8"

    ?>
  2. <

    RelativeLayout xmlns:

    android=

    "http://schemas.android.com/apk/res/android"
  3. xmlns:

    app=

    "http://schemas.android.com/apk/res-auto"
  4. xmlns:

    tools=

    "http://schemas.android.com/tools"
  5. android:

    layout_width=

    "match_parent"
  6. android:

    layout_height=

    "match_parent"
  7. tools:

    context=

    "com.razormist.simplesplashscreen.MainActivity"

    >

  8. <

    TextView
  9. android:

    id=

    "@+id/tv_loading"
  10. android:

    layout_height=

    "wrap_content"
  11. android:

    layout_width=

    "wrap_content"
  12. android:

    text=

    "LOADING"
  13. android:

    layout_centerInParent=

    "true"
  14. android:

    layout_above=

    "@+id/progressBar"
  15. android:

    textSize=

    "50sp"

    />

  16. <

    ProgressBar
  17. android:

    id=

    "@+id/progressBar"
  18. style=

    "@android:style/Widget.DeviceDefault.Light.ProgressBar.Horizontal"
  19. android:

    layout_width=

    "match_parent"
  20. android:

    layout_height=

    "wrap_content"
  21. android:

    progress=

    "0"
  22. android:

    layout_centerVertical=

    "true"
  23. android:

    layout_alignParentLeft=

    "true"
  24. android:

    layout_alignParentStart=

    "true"

    />
  25. </

    RelativeLayout>

Android Manifest File

The Android Manifest file provides essential information about your app to the Android system in which the system must required before running the code.
  1. <?

    xml version=

    "1.0"

    encoding=

    "utf-8"

    ?>
  2. <

    manifest xmlns:

    android=

    "http://schemas.android.com/apk/res/android"
  3. package

    =

    "com.razormist.simplesplashscreen"

    >

  4. <

    application
  5. android:

    allowBackup=

    "true"
  6. android:

    icon=

    "@mipmap/ic_launcher"
  7. android:

    label=

    "@string/app_name"
  8. android:

    roundIcon=

    "@mipmap/ic_launcher_round"
  9. android:

    supportsRtl=

    "true"
  10. android:

    theme=

    "@Style/AppTheme"

    >
  11. <

    activity android:

    name=

    ".MainActivity"
  12. android:

    configChanges=

    "orientation"
  13. android:

    screenOrientation=

    "portrait"

    >
  14. <

    intent-

    filter>
  15. <

    action android:

    name=

    "android.intent.action.MAIN"

    />

  16. <

    category android:

    name=

    "android.intent.category.LAUNCHER"

    />
  17. </

    intent-

    filter>
  18. </

    activity>
  19. </

    application>

  20. </

    manifest>

The Main Function

This code contains the main function of the application. This code will start running the progress bar to it target point and will load the new page at the same time. To create first locate your java file and open it, then write these block of codes.
  1. package

    com.razormist.simplesplashscreen

    ;

  2. import

    android.os.Handler

    ;
  3. import

    android.support.v7.app.AppCompatActivity

    ;
  4. import

    android.os.Bundle

    ;
  5. import

    android.widget.ProgressBar

    ;
  6. import

    android.widget.TextView

    ;

  7. public

    class

    MainActivity extends

    AppCompatActivity {
  8. ProgressBar progressBar;
  9. TextView loading;

  10. int

    progress =

    0

    ;
  11. Handler h =

    new

    Handler(

    )

    ;
  12. @Override
  13. protected

    void

    onCreate(

    Bundle savedInstanceState)

    {
  14. super

    .onCreate

    (

    savedInstanceState)

    ;
  15. setContentView(

    R.layout

    .activity_main

    )

    ;
  16. progressBar =

    (

    ProgressBar)

    findViewById(

    R.id

    .progressBar

    )

    ;
  17. loading =

    (

    TextView)

    findViewById(

    R.id

    .tv_loading

    )

    ;

  18. new

    Thread

    (

    new

    Runnable

    (

    )

    {
  19. @Override
  20. public

    void

    run(

    )

    {
  21. for

    (

    int

    i =

    0

    ;

    i <

    5

    ;

    i++

    )

    {
  22. progress +=

    20

    ;
  23. h.post

    (

    new

    Runnable

    (

    )

    {
  24. @Override
  25. public

    void

    run(

    )

    {
  26. progressBar.setProgress

    (

    progress)

    ;
  27. if

    (

    progress ==

    progressBar.getMax

    (

    )

    )

    {
  28. progressBar.setVisibility

    (

    4

    )

    ;
  29. loading.setText

    (

    "WELCOME"

    )

    ;
  30. }
  31. }
  32. }

    )

    ;
  33. try

    {
  34. Thread

    .sleep

    (

    3000

    )

    ;
  35. }

    catch

    (

    InterruptedException

    e)

    {

  36. }
  37. }
  38. }
  39. }

    )

    .start

    (

    )

    ;
  40. }
  41. }

Try to run the app and see if it worked.

There you have it we create a Simple Splash Screen using Android. I hope that this tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!!!

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.

2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.


Download
You must upgrade your account or reply in the thread to view the hidden content.
 

452,292

324,242

324,250

Top