简体   繁体   English

Android活动从底部到顶部以及从顶部到底部的黑色背景过渡

[英]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);

@Aniruddh Parihar, the black gap becomes a bit smaller. @Aniruddh Parihar,黑色间隙变小了。 But still have... 但是还是...

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Android中从下至上打开活动 - How to open activity from bottom to top in android 活动从下到上滑动但不应移动背景活动 - Activity sliding from bottom to top but background activity should not moved 从下到上显示活动 - Display Activity From Bottom to Top 如何从 android 中的 VLCVideoLayout 中删除顶部和底部黑条 - How to remove top and bottom black bar from VLCVideoLayout in android 顶部和底部的Android Alert对话框黑条 - Android Alert Dialog black bar on top and bottom 活动过渡效果:滑入顶部活动并缩放底部活动 - Activity transition effects: slide in for the top activity and scale for the bottom activity 从 AutoCompleteTextView 中删除顶部和底部的黑色边框 - Remove top and bottom black borders from AutoCompleteTextView 如何从屏幕底部到顶部启动 android 应用程序(不是活动)? - How to launch an android app(not an activity) from the bottom of the screen to top? 在Android中同时在活动顶部和底部添加标签 - Adding tabs in top and bottom of the activity simoultaneously in android Android ImageView 上从下到上和从上到下的布局动画点击 - Android Layout Animations from bottom to top and top to bottom on ImageView click
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM