2013-04-30 2 views
0

Я хочу изменить черный цвет в течение короткого периода, когда мое приложение запускается, но содержимое пока не отображается.ошибка при переходе от макета к другому расположению в android

этот черный цвет появляется при передаче от splash.xml до activity_main.xml, его требуется несколько минут и открыть мое приложение.

Мой StartPoint.java класс: -

public class StartPoint extends Activity{ 

ProgressBar progressBar; 
private int progressBarStatus = 0; 

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

    progressBar = (ProgressBar)findViewById(R.id.progressBar1); 


    Thread timer = new Thread(){ 
     public void run(){ 
      try{ 
       sleep(5000); 
       while(progressBarStatus < 5000){ 
        StartPoint.this.runOnUiThread(new Runnable(){ 
         public void run() 
         { 
          progressBar.setProgress(progressBarStatus); 
          progressBarStatus += 1000; 
         } 
        }); 

       } 
      }catch(InterruptedException e){ 
       e.printStackTrace(); 
      }finally{ 
       Intent openMainList = new Intent(StartPoint.this, com.example.kam.MainActivity.class); 
       startActivity(openMainList); 
      } 
     } 
    }; 
    timer.start(); 
} 

} 

и мой 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="vertical" > 

<ImageView 
    android:id="@+id/imageView1" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:src="@drawable/loading" /> 

<ProgressBar 
    android:id="@+id/progressBar1" 
    style="?android:attr/progressBarStyleHorizontal" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1.67" /> 

</LinearLayout> 

и activity_main.xml код: -

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

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:orientation="vertical" 
     > 

     <LinearLayout 
      android:layout_weight="6" 
      android:orientation="vertical" 
      android:layout_alignParentTop="true" 
      android:layout_alignParentLeft="true" 
      android:layout_width="fill_parent" 
      android:layout_height="0dip" > 

     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/buttons" 
      android:layout_width="match_parent" 
      android:layout_height="0dip" 
      android:layout_alignParentLeft="true" 
      android:layout_weight="0.62" 
      android:background="@drawable/iconbgrepate" 
      android:gravity="center" 
      android:orientation="horizontal" 
      android:tileMode="repeat" 
      android:weightSum="5" 
      android:alpha=".75"> 

     <SeekBar 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/volumebar" 
      android:max="100" 
      android:paddingBottom="10dip"/> 

     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/buttons" 
      android:layout_width="match_parent" 
      android:layout_height="0dip" 
      android:layout_alignParentLeft="true" 
      android:layout_weight="0.62" 
      android:background="@drawable/iconbgrepate" 
      android:gravity="center" 
      android:orientation="horizontal" 
      android:tileMode="repeat" 
      android:weightSum="5" > 

      <Button 
       android:id="@+id/btnRefresh" 
       android:layout_width="32dp" 
       android:layout_height="match_parent" 
       android:layout_margin="5dp" 
       android:layout_weight="0.10" 
       android:background="@drawable/refreshbutton" /> 

      <View android:layout_weight="1" 
       android:layout_width="0dip" 
       android:layout_height="0dip" /> 

      <Button 
       android:id="@+id/btnPause" 
       android:layout_width="32dp" 
       android:layout_height="match_parent" 
       android:layout_margin="5dp" 
       android:layout_weight="0.05" 
       android:background="@drawable/pausebutton" /> 

      <View android:layout_weight="1" 
       android:layout_width="0dip" 
       android:layout_height="0dip" /> 

      <Button 
       android:id="@+id/btnPlay" 
       android:layout_width="32dp" 
       android:layout_height="match_parent" 
       android:layout_margin="5dp" 
       android:layout_weight="0.05" 
       android:background="@drawable/playbutton" /> 

      <View android:layout_weight="1" 
       android:layout_width="0dip" 
       android:layout_height="0dip" /> 

      <Button 
       android:id="@+id/btnExit" 
       android:layout_width="32dp" 
       android:layout_height="match_parent" 
       android:layout_margin="5dp" 
       android:layout_weight="0.12" 
       android:background="@drawable/exitbutton" /> 

     </LinearLayout> 
    </LinearLayout> 
</RelativeLayout> 

и mainfest.xml: -

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.kam" 
    android:versionCode="1" 
    android:versionName="1.0" > 
    <uses-sdk 
     android:minSdkVersion="8" 
     android:targetSdkVersion="17" /> 
    <uses-permission android:name="android.permission.INTERNET" /> 
    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name="com.example.kam.StartPoint" 
      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="com.example.kam.MainActivity"/> 
    </application> 
</manifest> 

где моя проблема ??

ответ

0

Раскладка заставки нечетна тем, что у вас есть вес на одном из компонентов линейной компоновки, но не на другом. Я бы добавил весовую сумму или обеспечил вес для обоих. Если вы хотите, чтобы они потребляли одну и ту же сумму, используйте 1 и 1.

Кроме того, при работе с весами вы хотите иметь wrap_content в том же направлении (высота или ширина). Таким образом, дизайн там, вероятно, потребует некоторых настроек. Это первое, что я заметил.

+0

где и как я могу это сделать, я не понимаю вас, я - новое развитие Android –