Android SDK app: exclude status bar from transition animation

I followed the standard google SDK for google android and came to the conclusion that I can change the action bar options.

When another activity is opened, it appears as an animation (fade-in + grow). My problem is that the new action bar inside this activity appears along with the animation as well (all linked as one container). I want the action bar to persist on top, freeze while only the app content pops up. When the content of the action bar changes, it should just change without any animation. Let's take a look at the Telegram app as an example.

Since I've followed the standard tutorials, I'm assuming this is the default behavior, so it's probably usually to disable it, but I haven't found a working solution for it anywhere, so I have to ignore some very basic settings.

themes.xml:

...
<style name="BlaTheme"
       parent="@style/Theme.AppCompat">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <item name="android:actionBarTabTextStyle">@style/MyActionBarTabText</item>
    <item name="android:actionMenuTextColor">@color/actionbar_text</item>
    <item name="android:background">@color/darkpurple</item>
    <!-- Support library compatibility -->
    <item name="actionBarStyle">@style/MyActionBar</item>
    <item name="actionBarTabTextStyle">@style/MyActionBarTabText</item>
    <item name="actionMenuTextColor">@color/actionbar_text</item>
    <item name="android:windowActionBar">true</item>  
    <item name="android:windowContentOverlay">@null</item>
</style>

<!-- ActionBar styles -->
<style name="MyActionBar"
       parent="@style/Widget.AppCompat.ActionBar">
    <item name="android:background">@android:color/transparent</item>
    <item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
    <!-- Support library compatibility -->
    <item name="titleTextStyle">@style/MyActionBarTitleText</item>
</style>
...

      

+3


source to share


1 answer


You can define your transitions like this:

  • In the fade.xml file:

    <?xml version="1.0" encoding="utf-8"?>
    <transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
        <fade android:duration="500">
            <targets>
                <!--excluding status bar--> 
                <target android:excludeId="@android:id/statusBarBackground"/>
                <!--excluding navigation bar-->
                <target android:excludeId="@android:id/navigationBarBackground"/>
                <!--excluding toolbar bar-->
                <target android:excludeId="@id/toolbar"
            </targets>
        </fade>
    </transitionSet>
    
          

and then install it like:



    Transition mFadeTransition =
            TransitionInflater.from(this).
                    inflateTransition(R.transition.fade);

    getWindow().setEnterTransition(mFadeTransition);

      

  1. Or using just java:

    Fade fade = new Fade();
    fade.setDuration(500);
    //exclude toolbar
    fade.excludeTarget(R.id.toolbar, true);
    //exclude status bar
    fade.excludeTarget(android.R.id.statusBarBackground, true);
    //exclude navigation bar
    fade.excludeTarget(android.R.id.navigationBarBackground, true);
    
    getWindow().setEnterTransition(fade);
    
          

+4


source







All Articles