[英]Android activity transition from bottom to top and top to bottom black background issue
MainActivity with the navigation drawer, tabLayout and viewPager with three fragments. MainActivity具有导航抽屉,tabLayout和viewPager的三个片段。
Click on the fragment button, needs to invoke another activity. 单击片段按钮,需要调用另一个活动。 It needs the transition from "bottom to top" and when it back to main activity, it needs "top to bottom" transition. 它需要从“底部到顶部”的过渡,并且当它回到主要活动时,它需要从“顶部到底部”的过渡。
This is the main activity UI. 这是主要的活动UI。
Above is the transition from bottom to top. 上面是从底部到顶部的过渡。 I capture the screeshot during transition. 我在过渡期间捕获了快照。 I highlight with the red box. 我用红色框突出显示。 This is the issue. 这就是问题。 I see the black area. 我看到黑色区域。
My AppTheme is like that 我的AppTheme就是这样
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:colorBackground">@android:color/white</item>
<item name="alertDialogTheme">@style/AppCompatAlertDialogStyle</item>
</style>
But I don't want to see the black area in the transition, how to solve it. 但是我不想看到过渡中的黑色区域,如何解决它。 If needs to change to fragment, then I have another post with fragment, they have another more issues. 如果需要更改为片段,那么我还有另一篇有关片段的文章,他们还有另一个问题。 bottom_to_top_enter bottom_to_top_enter
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:duration="3000"
android:fromXDelta="0%"
android:fromYDelta="100%"
android:toXDelta="0%"
android:toYDelta="0%" />
</set>
Bottom_to_top_exit Bottom_to_top_exit
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="false">
<translate
android:duration="3000"
android:fromXDelta="0%"
android:fromYDelta="0%"
android:toXDelta="0%"
android:toYDelta="-100%" />
</set>
top_to_bottom_enter top_to_bottom_enter
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
android:shareInterpolator="false">
<translate
android:duration="3000"
android:fromXDelta="0%"
android:fromYDelta="-100%"
android:toXDelta="0%"
android:toYDelta="0%" />
</set>
top_to_bottom_exit top_to_bottom_exit
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:duration="3000"
android:fromXDelta="0%"
android:fromYDelta="0%"
android:toXDelta="0%"
android:toYDelta="100%" />
</set>
Thanks a lot. 非常感谢。
Try this : 尝试这个 :
Create anim folder inside your res folder and copy this four files : 在res文件夹中创建一个anim文件夹,然后复制以下四个文件:
slide_in_bottom.xml : slide_in_bottom.xml:
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="100%p"
android:duration="@android:integer/config_longAnimTime"/>
slide_out_bottom.xml : slide_out_bottom.xml:
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="0"
android:duration="@android:integer/config_longAnimTime" />
slide_in_top.xml : slide_in_top.xml:
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:toYDelta="0%p"
android:duration="@android:integer/config_longAnimTime" />
slide_out_top.xml : slide_out_top.xml:
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:toYDelta="100%p"
android:duration="@android:integer/config_longAnimTime" />
call this after calling start activity 致电开始活动后致电
overridePendingTransition(R.anim.slide_in_bottom, R.anim.slide_out_bottom);
or 要么
overridePendingTransition(R.anim.slide_in_top, R.anim.slide_out_top);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.