600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > Android自定义壁纸预览界面 解决Android启动显示空白界面的问题 自定义进入软件前的

Android自定义壁纸预览界面 解决Android启动显示空白界面的问题 自定义进入软件前的

时间:2023-02-05 10:41:19

相关推荐

Android自定义壁纸预览界面 解决Android启动显示空白界面的问题 自定义进入软件前的

1.新建xml文件

设置其背景图片 android:background="@mipmap/initmap"

xmlns:app="/apk/res-auto"

xmlns:tools="/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical"

android:background="@mipmap/initmap"

tools:context=".SplashActivity">

2.创建对应的Java文件

package com.example.testmap;

import android.app.Activity;

import android.content.Intent;

import android.os.Handler;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.view.WindowManager;

public class SplashActivity extends Activity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

setContentView(R.layout.activity_splash);

Handler handler = new Handler();

handler.postDelayed(new Runnable() {

@Override

public void run() {

goLoginActivity();

}

}, 1000);//界面显示时间

}

private void goLoginActivity(){

Intent intent = new Intent(this, MainActivity.class);

this.startActivity(intent);

this.finish();

}

}

Intent intent = new Intent(this, MainActivity.class);

MainActivity.class为你1s后将要进入的界面

3.然后再设置软件初始显示界面

注意:如果出现进不去的问题,

解决方法如下 :

把你的新建的xml文件可以改成

xmlns:app="/apk/res-auto"

xmlns:tools="/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical"

tools:context=".SplashActivity">

android:layout_width="match_parent"

android:layout_height="match_parent"

android:src="@mipmap/initmap2"/>

添加一个ImageView控件显示你的背景图片

Android自定义壁纸预览界面 解决Android启动显示空白界面的问题 自定义进入软件前的背景图片...

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。