android使用activity切换动画效果
16lz
2021-01-24
先创建2个activity
配置对应的布局文件和清单文件
我使用了2个透明度动画效果,放在res下的anim文件夹下
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="false"><alpha android:fromAlpha="0" android:toAlpha="1" android:duration="5000" /></set>
和
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="false"><alpha android:fromAlpha="1.0" android:toAlpha="0" android:duration="5000" /></set>
主activity
package cn.wonders.animation;import android.support.v7.app.ActionBarActivity;import android.view.View;import android.content.Intent;import android.os.Bundle;public class MainActivity extends ActionBarActivity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);}public void openActivity(View v) {Intent intent = new Intent(this, OtherActivity.class);startActivity(intent);//activity切换动画效果overridePendingTransition(R.anim.enteralpha, R.anim.outalpha);}}
布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/first_activity" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/open" android:onClick="openActivity" /></LinearLayout>另一个activity
package cn.wonders.animation;import android.support.v7.app.ActionBarActivity;import android.os.Bundle;public class OtherActivity extends ActionBarActivity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.other);}}
布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/second_activity" /></LinearLayout>
更多相关文章
- android camer 图片回显界面照片分享到微博、人人、彩信、蓝牙的
- 对RecycleView的多种item布局的封装
- ListView嵌套ListView时发生:View too large to fit into drawing
- Android(安卓)Audio 数据流详解
- Android(安卓)中自定义属性(attr.xml,TypedArray)的使用
- Android(安卓)编译 ijkplayer
- Android(安卓)Studio 混淆打包及常见第三方依赖的混淆配置
- Android解压及打包system.img
- 关于getSharedPreferences 使用注意条件