• android 项目学习随笔一(闪屏 )


    1、取标题栏且全屏

    <activity
    android:name="com.ecollab.zhsh66.SplashActivity"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />

    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>

    2、代码取掉标题

    requestWindowFeature(Window.FEATURE_NO_TITLE);必须在setContentView(R.layout.activity_main);之前执行

    3、整体旋转、缩放、渐变

    public class SplashActivity extends Activity {
    
        private RelativeLayout rlRoot;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_splash);
            rlRoot = (RelativeLayout) findViewById(R.id.rl_root);
            // 旋转, 缩放, 渐变
            // 旋转
            RotateAnimation animRotate = new RotateAnimation(0, 360,
                    Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
                    0.5f);
            animRotate.setDuration(1000);
            animRotate.setFillAfter(true);
    
            // 缩放
            ScaleAnimation animScale = new ScaleAnimation(0, 1, 0, 1,
                    Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
                    0.5f);
            animScale.setDuration(1000);
            animScale.setFillAfter(true);
    
            // 渐变
            AlphaAnimation animAlpha = new AlphaAnimation(0, 1);
            animAlpha.setDuration(2000);
            animAlpha.setFillAfter(true);
    
            // 动画集合
            AnimationSet animSet = new AnimationSet(true);
            animSet.addAnimation(animRotate);
            animSet.addAnimation(animScale);
            animSet.addAnimation(animAlpha);
    
            rlRoot.startAnimation(animSet);
    
            animSet.setAnimationListener(new AnimationListener() {
    
                @Override
                public void onAnimationStart(Animation animation) {
    
                }
    
                @Override
                public void onAnimationRepeat(Animation animation) {
    
                }
    
                @Override
                public void onAnimationEnd(Animation animation) {
                    // 判断是否需要跳到新手引导
                    boolean isGuideShow = PrefUtils.getBoolean("is_guide_show",
                            false, getApplicationContext());
    
                    if (isGuideShow) {
                        // 动画结束后跳主页面
                        startActivity(new Intent(getApplicationContext(),
                                MainActivity.class));
                    } else {
                        // 跳到新手引导
                        startActivity(new Intent(getApplicationContext(),
                                GuideActivity.class));
                    }
    
                    finish();
                }
            });
        }
    }
    View Code
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/rl_root"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/splash_bg_newyear" >
    
        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:src="@drawable/splash_horse_newyear" />
    
    </RelativeLayout>
    View Code
  • 相关阅读:
    介绍一个成功的 Git 分支模型 Release 分支
    启动安卓模拟器报错 emulator: ERROR: x86_64 emulation currently requires hardware acceleration! CPU acceleration status:HAXM must be updated(version 1.1.1<6.0.1) 解决办法
    AceyOffice教程复制行
    AceyOffice教程设置单元格边框
    Excel生成报表之解决方案合并单元格的用法
    AceyOffice教程报表之解决方案(二)
    Excel生成报表之解决方案插入图片
    AceyOffice教程复制列
    Excel基础知识(一)
    AceyOffice教程报表之解决方案(一)
  • 原文地址:https://www.cnblogs.com/ecollab/p/6027044.html
Copyright © 2020-2023  润新知