100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > android activity切换动画关闭 Activity取消界面切换的默认动画方法(推荐)

android activity切换动画关闭 Activity取消界面切换的默认动画方法(推荐)

时间:2019-01-21 20:49:06

相关推荐

android activity切换动画关闭 Activity取消界面切换的默认动画方法(推荐)

一般启动一个新的activity都默认有切换的动画效果,比如界面从右至左的移动。

但是有些时候我们不需要这个动画,怎么办?

操作方法比较麻烦,这里我推荐其中一种。我这里是要做启动页splash到首页home无缝展示,即启动页的图片背景和首页最上层的悬浮背景图是一模一样,用户会以为还在启动页,我这里会做些动画,然后进行开门效果。(首页会多出2个按钮,此时就不是启动页了)

主要实现思路:

1、需要设置无动画效果的主题,应用到对应的界面。

2、在启动页面界面结束时,需要增加一个方法 overridependingtransition(0, 0);

在splashactivity.this.finish();之前。

3、gif中启动页面和首页都是同一个图片(首页布局上面悬浮了启动页的图片,利用window的decorview)

4、在style.xml里,需要加入下面主题,其中parent=”apptheme”中的父主题是你应用自身的主题,name=”theme”的theme是即将需要使用的。接下来在首页的android:theme=”@style/theme”设置到你的首页(即你启动页跳转的下一级页面)。

@style/animation

@null

@null

@null

@null

@null

@null

@null

@null

@null

@null

@null

@null

5、如果需要实现gif中效果,防止启动页的图片可能延伸到状态栏,我这边加了占位布局(高度为动态获取的系统状态栏高度,代码是在启动页获取高度)。

@override

public void onwindowfocuschanged(boolean hasfocus) {

super.onwindowfocuschanged(hasfocus);

int statusbarheight = getstatusbarheight();

preferencesutil.putint(this, preferencekey.setting, preferencekey.status_bar_height,

statusbarheight);

logutil.e(statusbarheight + "");

}

public int getstatusbarheight() {

int result = 0;

int resourceid = getresources().getidentifier("status_bar_height", "dimen", "android");

if (resourceid > 0) {

result = getresources().getdimensionpixelsize(resourceid);

}

return result;

}

以上就是小编为大家带来的activity取消界面切换的默认动画方法(推荐)全部内容了,希望大家多多支持萬仟网~

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。