5

In the booting of my application, I wanted to have a splash screen that resembles image slide. By swiping left or right, you can have a brief view of functions of the app. Somewhere at the bottom of each image, I wanted to fix a menu like item to show a navigation of the images. it can simply be a chain of solid circles which tell user which image they are at.

any one tell me what's the term for this kind of splash screen and how can I do that?

Thanks

Daniel
  • 1,484
  • 5
  • 24
  • 42

2 Answers2

2

I think u want to display Multiple Images in a Splashscreen.In the Below Activity, it has a ImageView which displays Multiple Images & the Images can be displayed at diferennt Time intervals.

Splash.java

public class Splash extends Activity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_splash);
            final ImageView splashImageView = (ImageView) findViewById(R.id.SplashImageView);
            splashImageView.setBackgroundResource(R.anim.splash);
            final AnimationDrawable frameAnimation = (AnimationDrawable)splashImageView.getBackground(); 
                            Thread timer= new Thread(){
                                                        public void run(){
                    try{
                                    sleep(7000);
                    }catch(InterruptedException e){
                    e.printStackTrace();
                }finally {
                    Intent splash =new Intent("com.arul.remoteit.Main");
                    startActivity(splash);
                }
                }
            };
        timer.start();
            splashImageView.post(new Runnable(){
                @Override
                public void run() {
                    frameAnimation.start();    
                               }            
            });
                }
    @Override
            protected void onPause() {
                // TODO Auto-generated method stub
                super.onPause();
                finish();
            }

        }

In this XML file you have to specify the Images which has to be displayed.Here i have 5 images which is displayed at particular intervals.

splash.xml

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/flaganim"
    android:oneshot="false"
    >
    <item android:drawable="@drawable/s1" android:duration="1000" />
    <item android:drawable="@drawable/s2" android:duration="1000" />
    <item android:drawable="@drawable/s3" android:duration="1000" />
     <item android:drawable="@drawable/s4" android:duration="1000" />
    <item android:drawable="@drawable/s5" android:duration="1000" />
    </animation-list>
AruLNadhaN
  • 2,808
  • 5
  • 24
  • 42
-2

Just create a xml file with a image as background like below.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <ImageSwitcher android:id="@+id/switcher"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
    />

    <Gallery android:id="@+id/gallery"
        android:background="#55000000"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"

        android:gravity="center_vertical"
        android:spacing="16dp"
    />

</RelativeLayout>

for this Activity:

public class MainActivity extends Activity implements
        AdapterView.OnItemSelectedListener, ViewSwitcher.ViewFactory {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.activity_main);

        mSwitcher = (ImageSwitcher) findViewById(R.id.switcher);
        mSwitcher.setFactory(this);
        mSwitcher.setInAnimation(AnimationUtils.loadAnimation(this,
                android.R.anim.fade_in));
        mSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this,
                android.R.anim.fade_out));

        Gallery g = (Gallery) findViewById(R.id.gallery);
        g.setAdapter(new ImageAdapter(this));
        g.setOnItemSelectedListener(this);
    }

    public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
        mSwitcher.setImageResource(mImageIds[position]);
    }

    public void onNothingSelected(AdapterView<?> parent) {
    }

    public View makeView() {
        ImageView i = new ImageView(this);
        i.setBackgroundColor(0xFF000000);
        i.setScaleType(ImageView.ScaleType.FIT_CENTER);
        i.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.MATCH_PARENT));
        return i;
    }

    private ImageSwitcher mSwitcher;

    public class ImageAdapter extends BaseAdapter {
        public ImageAdapter(Context c) {
            mContext = c;
        }

        public int getCount() {
            return mThumbIds.length;
        }

        public Object getItem(int position) {
            return position;
        }

        public long getItemId(int position) {
            return position;
        }

        public View getView(int position, View convertView, ViewGroup parent) {
            ImageView i = new ImageView(mContext);

            i.setImageResource(mThumbIds[position]);


            if(position==25)
            {

                Intent intent = new Intent(MainActivity.this, NextActivity.class);
                startActivity(intent);
        finish();

            }


            i.setAdjustViewBounds(true);
            i.setLayoutParams(new Gallery.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            i.setBackgroundResource(R.drawable.a);
            return i;
        }

        private Context mContext;

    }

    private Integer[] mThumbIds = {
            R.drawable.a, R.drawable.b, R.drawable.c,
            R.drawable.d, R.drawable.e, R.drawable.f,
            R.drawable.g, R.drawable.h, R.drawable.i,
            R.drawable.j, R.drawable.k, R.drawable.l,
            R.drawable.m, R.drawable.n, R.drawable.o,
            R.drawable.p, R.drawable.q, R.drawable.r,
            R.drawable.s, R.drawable.t, R.drawable.u,
            R.drawable.v, R.drawable.w, R.drawable.x,
            R.drawable.y, R.drawable.z
            };

    private Integer[] mImageIds = {
            R.drawable.a, R.drawable.b, R.drawable.c,
            R.drawable.d, R.drawable.e, R.drawable.f,
            R.drawable.g, R.drawable.h, R.drawable.i,
            R.drawable.j, R.drawable.k, R.drawable.l,
            R.drawable.m, R.drawable.n, R.drawable.o,
            R.drawable.p, R.drawable.q, R.drawable.r,
            R.drawable.s, R.drawable.t, R.drawable.u,
            R.drawable.v, R.drawable.w, R.drawable.x,
            R.drawable.y, R.drawable.z
            };

}

In this code i intent from MainActivity to NextActivity , like tat do. Add a to z 26 images, or use how mush you need according to that change the position if condition. I used 26 images in this, At position 25 i intent to next activity.This wat you asked ryt ? Accept answer if you got wat you want, update me if any queries .

Don't forgot to add Both activity to mainfest. And main think that you need to specify splash activity first like below.

 <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".splash"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" />




    </application>
kathir
  • 489
  • 2
  • 11
  • Could you tell me which statement helps embed multiple images? one splash screen should contain many images that can be swiped left and right – Daniel Dec 31 '13 at 11:22
  • Splash screen is to show a image at the time of application starting. Multiple images means , wat you specifying.? – kathir Dec 31 '13 at 11:26
  • Accept my answer tat wat you want, and update me you got wat you need. Happy coding dude :) – kathir Dec 31 '13 at 11:27
  • like you have a tabular at the bottom, you can swipe by images and when you swipe by the last image, you would enter the main activity – Daniel Dec 31 '13 at 11:36
  • besides what's the option menu here – Daniel Dec 31 '13 at 11:38