First put the start page in the project resource, the picture is generally 1080*1920 jpg.
Create a new activity,
After the creation is successful, open the activity you just created to write the code:
public class BZLaunchActivity extends AppCompatActivity { private final int SPLASH_DISPLAY_LENGHT = 2000;//两秒后进入系统,时间可自行调整 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_bzlaunch); //在BZLaunchActivity停留2秒然后进入BZLaunchActivity new android.os.Handler().postDelayed(new Runnable() { @Override public void run() { Intent mainIntent = new Intent(BZLaunchActivity.this,MainActivity.class); BZLaunchActivity.this.startActivity(mainIntent); BZLaunchActivity.this.finish(); } },SPLASH_DISPLAY_LENGHT); }}
Then go to the XML config file to draw the interface, the configuration file in Res/layout with the creation of the same name of the XML file, the code is as follows:
<?xml version= "1.0" encoding= "Utf-8"? ><android.support.constraint.constraintlayout xmlns: Android= "Http://schemas.android.com/apk/res/android" xmlns:app= "Http://schemas.android.com/apk/res-auto" xmlns: tools= "Http://schemas.android.com/tools" android:layout_width= "match_parent" android:layout_height= "match_parent "Tools:context=". Bzlaunchactivity "> <imageview android:id=" @+id/imageview "android:layout_width=" Wrap_content " android:layout_height= "wrap_content"//Let the picture Display full screen android:scaletype= "Fitxy" App:layout_constraintbotto m_tobottomof= "Parent" app:layout_constraintend_toendof= "parent" app:layout_constraintstart_tostartof= "parent" "app:layout_constrainttop_totopof=" parent "//start Page picture app:srccompat=" @mipmap/zqq_launch "/></andr Oid.support.constraint.constraintlayout>
If the android:scaletype= "Fitxy" is not set, the start page picture may appear without full screen condition.
Finally go to the Androidmanifest.xml file to modify the Start page activity of the location, not modified before, mainactivity is in front, this time to run the app, found that there is no launch page, we need to transfer the activation page activity to mainactivity Front, i.e.:
<activity android:name=".BZLaunchActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
Well, finish this, and then run the app and you'll see the startup page.
"Android" Mac under Android Studio Settings App launch page