zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    模版的完全特化与偏特化
    [转]windows消息机制(MFC)
    MFC宏常识
    半透明AlphaBlend
    new、operator new、placement new
    DuplicateHandle
    Mac OS X 更新JAMF域控配置
    生成自签名CA+SSL证书
    Office 2016系列下载地址
    Spring Security静态资源访问
  • 原文地址:https://www.cnblogs.com/jerrywublogs/p/7125117.html
Copyright © 2011-2022 走看看