"Android" Mac under Android Studio Settings App launch page

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.