活动过渡忽略工具栏 [英] Activity transition ignoring Toolbar

查看:141
本文介绍了活动过渡忽略工具栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们看看是否有人可以帮助我.

let's see if someone can help me with this.

在我的应用中,我已经成功实现了大多数活动之间的幻灯片过渡.我所有的活动布局都包含在常规工具栏中,并在下面包含一些内容.所以我想让动画忽略工具栏,只影响主要内容.

In my app I have successfully implemented slide transitions between most of my activities. All my activities layouts consist in a regular toolbar and some content below. So what I would like is the animations to ignore the toolbar and only affect the main content.

理想情况下,工具栏将保留在其位置,而布局的主要内容将是滑动.

Ideally, the toolbar would remain in its place and the main content of the layout would be the one sliding.

为完成该问题,这是我的转换xml之一:

For completion of the question, here is one of my transition xmls:

<?xml version="1.0" encoding="utf-8"?>

<translate
    android:duration="500"
    android:fromXDelta="100%"
    android:toXDelta="0%" >
</translate>

这是我设置过渡的方式:

and this is the way I'm setting transitions:

overridePendingTransition(R.transition.out, R.transition.in);

谢谢

推荐答案

好的,所以我花了几个小时才找到答案.我在android 7.1中遇到了一些问题.除此之外,它还可以在5.x和6.x

Alright, so I found the answer after some hours working on it. I'm having some issues in android 7.1. Other than that, it works in 5.x and 6.x

<?xml version="1.0" encoding="utf-8"?>
<slide
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:slideEdge="right"
    android:duration="500">
    <targets>
        <target android:excludeId="@id/toolbar"/>
        <target android:excludeId="@android:id/statusBarBackground"/>
        <target android:excludeId="@android:id/navigationBarBackground"/>
    </targets>
</slide>

如您所见,您可以添加动画将忽略的视图.就我而言,是工具栏,状态和导航栏.

As you can see, you can add views to be ignored by the animation. In my case, the toolbar, status and navigation bar.

然后,您可以按照自己喜欢的方式应用动画,它将影响除指定要忽略的元素以外的所有内容.

Then you can apply the animation the way you prefer, it will affect everything but the elements specified to be ignored.

这篇关于活动过渡忽略工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆