Android App 开机启动画面和开机自动启动APP程序设置

1、当前比较成熟一点的应用基本上都会在进入应用之显示一个启动界面

如腾讯微博

2、准备元素

   需要开机启动的图片一张

3、新建Activity

AlphaAnimation动画:控制对象alpha水平的动画。这个动画可以通过改变alpha属性,达到渐进渐出的效果。

public class SplashActivity  extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final View view = View.inflate(this, R.layout.splash, null);
        setContentView(view);

        /** 设置透明度渐变动画 */
        AlphaAnimation aa = new AlphaAnimation(0.3f, 1.0f);
        aa.setDuration(2000);//设置动画持续时间
        view.startAnimation(aa);  // 绑定动画效果
         aa.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationEnd(Animation arg0) {
                //渐变动画结束后,执行此方法,跳转到主界面
                redirectTo();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationStart(Animation animation) {
            }
        });

    }

    private void redirectTo() {
        Intent intent = new Intent(this, index.class);
        startActivity(intent);
        finish();
    }
}
View Code

 4、添加 layout 元素

<?xml version="1.0" encoding="utf-8"?>
<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"
    tools:context=".SplashActivity" >

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/ico"
        android:scaleType="fitCenter" />

</RelativeLayout>
View Code

5、设置 AndroidManifest.xml

   5.1、设置开机启动页面   

 <activity
            android:name=".SplashActivity"
            android:configChanges="keyboardHidden"
            android:label="@string/app_name"
            android:launchMode="singleTask"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />

                <category android:name="android.intent.category.HOME"/>
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
View Code

  5.2、设置安卓桌面状态(开机自动启动APP,需要厂家根据APP定制或者设置)

<category android:name="android.intent.category.HOME"/>
                <category android:name="android.intent.category.DEFAULT" />
View Code

 

转载于:https://www.cnblogs.com/jerrywublogs/p/7125117.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值