Android(安卓)APP欢迎界面小试身手
16lz
2021-01-26
这是Anny第一次写博客,可谓是处女座啊。写的不好还请手下留情。
第一次写博客,一时间还真的不知道该写些什么内容,思前想后还是来说说比较简单的欢迎界面吧。欢迎动画,说是动画,个人理解也可以不是动画。想要实现的效果无非是类似微信,一张图片闪过;或者像QQ,几张宣传页飘过。第一次写就简单的讲解一下,像微信的那种闪过一张图片的欢迎动画的实现原理。
[1、anim资源文件][anim]
welcom_alpha.xml
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="2000" /> <alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:startOffset="3000" android:duration="3000" />set>
[2、欢迎界面布局][welcom_lay]
activity_welcom.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout 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" android:orientation="vertical" tools:context="com.cl.chengl.WelcomAct"> <ImageView android:id="@+id/welcomImg" android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/trim" android:scaleType="fitXY" />LinearLayout>
[3、欢迎activity][welcom_act]
import android.content.Intent;import android.os.Bundle;import android.app.Activity;import android.view.Window;import android.view.animation.Animation;import android.view.animation.AnimationUtils;import android.widget.ImageView;public class WelcomAct extends Activity implements Animation.AnimationListener{ private ImageView img=null; private Animation anim=null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_welcom); img=(ImageView)this.findViewById(R.id.welcomImg); anim= AnimationUtils.loadAnimation(this,R.anim.welcom_alpha); anim.setFillEnabled(true); anim.setFillAfter(true); img.setAnimation(anim); anim.setAnimationListener(this); } @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { startActivity(new Intent(this,MainActivity.class)); finish(); } @Override public void onAnimationRepeat(Animation animation) { }}
[4、别忘记了要注册activity][]
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.cl.chengl" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme"> <activity android:name=".MainActivity" android:label="@string/app_name"> activity> <activity android:name=".WelcomAct" android:label="@string/title_activity_welcom"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> intent-filter> activity> application>manifest>
[5、图片资源][img]
[6、效果截图][img1]
更多相关文章
- android 新交互方式
- Android(安卓)动画框架详解(第 1 部分)
- Gallery控件初体验——简单的相册
- Android(安卓)实现人脸识别检测时的扫描动画效果(二维码扫描动画
- ANDROID缩略图Thumbnails
- 摄像头的使用之(Camera的使用)
- android 拍照的照片方向问题,读取图片EXIF信息
- Android获取并显示图片
- 教你快速实现Android动态模糊效果