开发者

Android: Keyboard shown in the splash screen

I wrote a splash screen. But the problem is as the splash screen shown in the screen a keyboard also invoked. What could be the possible reason for this??

Please find the image below

Android: Keyboard shown in the splash screen

and the code gos as below for the activity

public class SplashActivity extends Activity{

    private final int SPLASH_DISPLAY_LENGHT = 2000;

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

        /* New H开发者_Go百科andler to start the Menu-Activity

         * and close this Splash-Screen after some seconds.*/

        new Handler().postDelayed(new Runnable(){

                @Override

                public void run() {

                        /* Create an Intent that will start the Menu-Activity. */

                        Intent splash2 = new Intent(SplashActivity.this,SplashActivityRed.class);

                        SplashActivity.this.startActivity(splash2);

                        SplashActivity.this.finish();
                        overridePendingTransition(R.anim.fadein,R.anim.fadeout);
                }

        }, SPLASH_DISPLAY_LENGHT);

    }



}

and the xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
    <ImageView android:id="@+id/imageViewSplash" android:layout_height="fill_parent" android:layout_width="fill_parent" android:background="@drawable/splash1" android:src="@drawable/splash1"></ImageView>
</LinearLayout> 

PS: Sorry I had to hide the text and logo as they come under non-disclosure policy of the company I work for.


Please Remove the imageView from the Layout and add the following line the Linear Layout element

 android:background="@drawable/splash1"

Like this:

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

Hope this helps

Also Change the implementation of the SplashScreen with above layout. To change the time line change the value of welcomeScreenDisplay to wotever you want. Currently it is 4 seconds i.e. 4000 mili seconds.

public class SplashScreen extends Activity {
String status, subscriber;
Intent i = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    System.out.println("FIRST");
    setContentView(R.layout.splash);
    System.out.println("in HOME SCREEN");
    /** set time to splash out */
    final int welcomeScreenDisplay = 4000;
    /** create a thread to show splash up to splash time */
    Thread welcomeThread = new Thread() {

    int wait = 0;

    @Override
    public void run() {
    try {
    super.run();
    /**
    * use while to get the splash time. Use sleep() to increase
    * the wait variable for every 100L.
    */
    while (wait < welcomeScreenDisplay) {
    sleep(100);
    wait += 100;
    }
    } catch (Exception e) {
    System.out.println("EXc=" + e);
    } finally {
    /**
    * Called after splash times up. Do some action after splash
    * times up. Here we moved to another main activity class
    */


  finish();
    }
    }



    };
    welcomeThread.start();


}
}


Use this method:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_‌​HIDDEN);


probably you need to disable the touch event for image. However as remove the imageView from the Layout and add background image to the linear layout element

android:background="@drawable/splash1"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜