Android 应用启动欢迎界面广告的实现实例应用启动欢迎界面广告的实现实例
主要介绍了Android 应用启动欢迎界面广告的相关资料,需要的朋友可以参考下
Android 应用启动欢迎界面广告应用启动欢迎界面广告
0.写在前面写在前面
在这篇教程中来实现一个类似于微信的的延迟3秒再进入主界面的效果。
1.项目准备项目准备
先新建一个空的android项目。里面只自带一个MainActivity,首先我们再新建一个Activity叫做WelcomeActivity继承自
Activity。
Activity代码如下:
//package在此省略,根据实际自行添加
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
/**
* Created by HUPENG on 2016/9/21.
*/
public class WelcomeActivity extends Activity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
}
}
布局文件代码如下:布局文件代码如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView"
android:layout_gravity="center_horizontal"
android:src="@mipmap/welcome"/>
<!--android src属性指定imageView里面要显示的资源文件的来源路径,也就是在欢迎界面显示的图片,在这里我已经预先上传了一张图片了-->
</LinearLayout>
修改清单文件AndroidManifest.xml
声明WelcomeActivity以及修改Activity的启动顺序,由MainActivity改成WelcomeActivity
原来的xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="supershare.android.hupeng.me.supershare">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
评论0