Java 启动屏幕问题(启动时没有图像,主页上没有文本)
因此,我尝试为我正在尝试制作的android应用程序实现一个闪屏。然而,在研究了许多堆栈溢出解决方案之后,似乎没有一个能够解决这个问题 有几个问题:Java 启动屏幕问题(启动时没有图像,主页上没有文本),java,android,eclipse,screen,splash-screen,Java,Android,Eclipse,Screen,Splash Screen,因此,我尝试为我正在尝试制作的android应用程序实现一个闪屏。然而,在研究了许多堆栈溢出解决方案之后,似乎没有一个能够解决这个问题 有几个问题: 当启动屏幕过渡到主屏幕时,主屏幕上只有白色的操作栏,没有“Hello World!” 启动屏幕本身是相当黑的。不是漆黑一片,但它要么就是不显示图片,要么就是显示了最上面的25%。我使用的启动屏幕位于此处:(仅用于测试目的) 因此,这是两个最大的问题。闪屏在正确的时间转换,但出现了这些奇怪的小故障。这是我的密码 MainActivity.java @
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public class SplashActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent i = new Intent(SplashActivity.this, MainActivity.class);
SplashActivity.this.startActivity(i);
SplashActivity.this.finish();
}
}, 3000);
}
fragment_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.studyapp.MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</RelativeLayout>
fragment_splash.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView android:id="@+id/splashscreen"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:src="@drawable/splash"/>
</LinearLayout>
最后是舱单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.studyapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19"
android:screenOrientation="portrait"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name="com.example.studyapp.MainActivity"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.example.studyapp.SplashActivity"
android:label="@string/title_activity_splash"
android:theme="@style/Theme.Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
谢谢你的帮助!我已经在这个问题上纠缠了好几个小时。你能发布activity\u main.xml吗?这就是您在活动代码中引用的内容(并将布局设置为)。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.studyapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19"
android:screenOrientation="portrait"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name="com.example.studyapp.MainActivity"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.example.studyapp.SplashActivity"
android:label="@string/title_activity_splash"
android:theme="@style/Theme.Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>