0

我在打开应用程序时尝试了很多方法来获取启动屏幕,但无法像链接的 android 移动应用程序主屏幕一样。这里我需要在第一张幻灯片中显示大图像的一部分,然后在 2 秒后它会自动移动从右到左并显示带有文本和可点击按钮的图像的第二部分。如何实现它请帮助我。

这是移动应用程序中的链接:https ://play.google.com/store/apps/details?id=com.linkedin.android&hl=en

我试过了,但没有得到我想要的

public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.first);
        //display the logo during 2 seconds,
        new CountDownTimer(2*1000,1000){
            @Override
            public void onTick(long millisUntilFinished){} 

            @Override
            public void onFinish(){
                   //set the new Content of your activity
                   YourActivity.this.setContentView(R.layout.second);
            }
       }.start();
    }
4

1 回答 1

0
    As per my understanding you require splash screen ..

    Splash.java
    ---------------

    public class Splash extends Activity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            setContentView(R.layout.activity_splash);

            Thread logoTimer = new Thread() {
                public void run() {
                    try {
                        int logoTimer = 0;
                        while (logoTimer < 3000) {
                            sleep(100);
                            logoTimer = logoTimer + 100;
                        }

                        Intent intent = new Intent(Splash.this, NewClassToOpen.class);
                        startActivity(intent);

                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } finally {
                        finish();
                    }
                }
            };
            logoTimer.start();
        }

    }

    activity_splash.xml
    -------------------


    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:background="@drawable/splash"
         >

    </LinearLayout>

    @drawable/splash --- > Place image to drawable folders with name "splash / or as you need"

This is for left to right animation:

<set xmlns:android="http://schemas.android.com/apk/res/android"
     android:shareInterpolator="false">
  <translate android:fromXDelta="-100%" android:toXDelta="0%"
             android:fromYDelta="0%" android:toYDelta="0%"
             android:duration="700"/>
</set>

This is for right to left animation:

<set xmlns:android="http://schemas.android.com/apk/res/android"
     android:shareInterpolator="false">
  <translate
     android:fromXDelta="0%" android:toXDelta="100%"
     android:fromYDelta="0%" android:toYDelta="0%"
     android:duration="700" />
</set>

    Enjoy .. Cheers ! 
于 2013-11-07T06:08:40.480 回答