android 启动页
2015-11-24 17:59
423 查看
在android项目中一定存在的模块,一定是AppStart模块了。
分享代码如下:
布局文件为
动画文件为
分享代码如下:
package com.weidingqiang.custommooc; import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.WindowManager; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ImageView; /** * 启动页面 */ public class MainActivity extends AppCompatActivity { private static final String TAG = MainActivity.class.getSimpleName(); private static final String First = "first"; private ImageView imageView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //设置全屏 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_main); imageView = (ImageView) this.findViewById(R.id.iconImageView); initAnimation(); } /** * 初始化动画 */ private void initAnimation(){ Animation animation = AnimationUtils.loadAnimation(this,R.anim.start_anim); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { jump(); } @Override public void onAnimationRepeat(Animation animation) { } }); imageView.startAnimation(animation); } /** * 动画完成 */ private void jump(){ //查看是否第一次打开 //如果首次打开 则跳转到介绍页面 //否则直接进入主界面 SharedPreferences sharedPreferences= getSharedPreferences(TAG, Activity.MODE_PRIVATE); boolean isfrist = sharedPreferences.getBoolean(First, true); Intent jumpintent = new Intent(); if(isfrist){ //第一次 运行介绍界面 SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putBoolean(First,false); editor.commit(); } else { } startActivity(jumpintent); finish(); } }
布局文件为
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@mipmap/loading_main_bg" > <ImageView android:id="@+id/iconImageView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@mipmap/loading_main_bottom" android:layout_alignParentBottom="true" android:layout_marginBottom="30dp" android:layout_centerHorizontal="true" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/copyright" android:layout_alignParentBottom="true" android:layout_marginBottom="8dp" android:gravity="center" android:layout_centerHorizontal="true" android:textSize="10sp" /> </RelativeLayout>
动画文件为
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:duration="2000"> <alpha android:fromAlpha="0.9" android:toAlpha="1.0"/> </set>
相关文章推荐
- Android -eventbus的初步使用 和 OnSharedPreferenceChangeListener (SharedPreference内容改变)监听
- Android LruCache图片缓存使用(二)
- Android ListView item项 显示动画
- Android 窗口全屏
- Android学习笔记系列开篇
- Android中notifyDataSetInvalidated()和notifyDataSetChanged()的区别
- Android获取相册中图片的路径 4.4版本前后的变化
- android 实现滑动切换activity
- Android SDk Manager 目前可用的更新ip
- android ViewPager滑动事件讲解
- Windows环境下Android Studio v1.0安装教程、快捷方式
- <3>Android HAL如何向上层提供接口总结
- Android res/raw文件;raw与res/assets异同
- android 布局 实现底部表单中底部按钮悬浮
- android编译分析之7—product_config.mk
- Android 中一个工程引用另一个工程
- android编译分析之6—device.mk
- Android中Unable to execute dex: Multiple dex files define Lcom/ta/utdid2/android/utils/AESUtils;解决方法
- 在android 源码里 编译 aidl 报错 的问题
- android:windowSoftInputMode 属性介绍