布局:新布局到来时,仍会显示启动画面背景

时间:2013-03-22 11:56:30

标签: android layout splash-screen

我的布局有问题。在我的活动中,我首先显示一个启动画面,然后根据某些条件我需要显示不同的布局。当我显示一个布局时,它看起来像透明的白色(如飞溅视图),其他一个是好的,因为它的背景颜色是匹配的用它。 当我按下透明的白色视图(文本视图)时,它看起来很正常。也就是说它在按下和释放不同视图的意义上充当按钮。

我试着提供背景颜色,但仍然存在问题。不幸的是,我只需要为该视图提供白色。

任何人都可以帮我改变我的新布局中显示的透明白色

这是具有背景问题的视图布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@color/white"  
 >

<ScrollView 
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:layout_marginLeft="5dp"
 android:layout_marginRight="5dp"
 >
 <RelativeLayout 
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
     >
   <TextView
     android:id="@+id/abc"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"

      />
     </RelativeLayout>   
 </ScrollView>

<RelativeLayout 
     android:id="@+id/button_layout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"

    android:paddingBottom="5dp"
    >

<Button 
    android:id="@+id/btn1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:text="@string/btn1"
    android:background="@drawable/btn1"


    />
 <Button 
    android:id="@+id/btn2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:text="@string/btn2"
    android:background="@drawable/btn2" 
   />

</RelativeLayout>

代码

oncreate(){
setcontentview(splashscreen)
setview()
}

void setview(){
if(condition1){
            setContentView(R.layout.a1);

}
else{
       setContentView(R.layout.a2);
}
}

1 个答案:

答案 0 :(得分:2)

为什么不在飞溅结束时转移到另一个活动?像this一样。只是为了SO,我在这里复制该页面的代码:

package com.itcuties.tutorial.android;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;


public class SplashActivity extends Activity {

   private static String TAG = SplashActivity.class.getName();
   private static long SLEEP_TIME = 5;    // Sleep for some time

   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);

      this.requestWindowFeature(Window.FEATURE_NO_TITLE);    // Removes title bar
      this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);    // Removes notification bar

      setContentView(R.layout.splash);

      // Start timer and launch main activity
      IntentLauncher launcher = new IntentLauncher();
      launcher.start();
   }

   private class IntentLauncher extends Thread {
      @Override
      /**
       * Sleep for some time and than start new activity.
       */
      public void run() {
         try {
            // Sleeping
            Thread.sleep(SLEEP_TIME*1000);
         } catch (Exception e) {
            Log.e(TAG, e.getMessage());
         }

         // Start main activity
         Intent intent = new Intent(SplashActivity.this, MainActivity.class);
         SplashActivity.this.startActivity(intent);
         SplashActivity.this.finish();
      }
   }
}
相关问题