我想在我的应用程序启动但内容尚未显示的短时间内更改黑色。
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>
我的问题在哪里??