Android:启动画面中显示的键盘

时间:2011-08-01 04:12:10

标签: android android-softkeyboard splash

我写了一个闪屏。但问题是屏幕上显示的启动画面也会调用键盘。这可能是什么原因?

请找到下面的图片 enter image description here

以及活动

的代码gos如下所示
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 Handler 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);

    }



}

和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:对不起,我不得不隐藏文字和徽标,因为它们属于我所在公司的保密政策。

3 个答案:

答案 0 :(得分:1)

请从布局中删除imageView,并在线性布局元素

中添加以下行
 android:background="@drawable/splash1"

像这样:

<?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>  

希望这有帮助

同时使用上面的布局更改SplashScreen的实现。要更改时间线,请将welcomeScreenDisplay的值更改为您想要的wotever。目前是4秒,即4000毫秒。

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();


}
}

答案 1 :(得分:1)

使用此方法:

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

答案 2 :(得分:0)

可能您需要禁用图像的触摸事件。但是,从布局中删除imageView并将背景图像添加到线性布局元素

android:background="@drawable/splash1"