skip to Main Content

I am currently making a chat app and i want to add a feature like telegram. As you can see here, there is a animation in the recycler view as if i=t zooming or decreasing its size. You can also notice that animation while opening and closing the navigation drawer. I too tried to do that using this but i get no animation in the recycler view. See this. Actually not this but like this. I took this gif from the README of the repo. So is that possible? If so, can you please tell me a simple implementation ?

Thanks in advance and i will be waiting 😀

2

Answers


  1. Add overridePendingTransition in onBackPressed() method:

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        overridePendingTransition(0, R.anim.slide_out_right);
    }
    

    res->anim->slide_out_right.xml

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android">
        <translate
            android:duration="@android:integer/config_mediumAnimTime"
            android:fromXDelta="0"
            android:toXDelta="100%p" />
    </set>
    
    Login or Signup to reply.
  2. To me it looks like an Activity transition where the translateZ value is modified. But since the Telegram Android client is open source, we can just take a look at it.

    It looks like the Telegram devs use a lot of custom code instead of relying on the android SDK.

    The DialogsActivity which extends a BaseFragment but is neither an Android Activity nor an Android Fragment since BaseFragmentdoesn’t extend any of them, has the following method for the transition:

        private void setSlideTransitionProgress(float progress) {
            if (SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_LOW) {
                return;
            }
            slideFragmentProgress = progress;
            if (fragmentView != null) {
                fragmentView.invalidate();
            }
    
            if (filterTabsView != null) {
                float s = 1f - 0.05f * (1f - slideFragmentProgress);
                filterTabsView.getListView().setScaleX(s);
                filterTabsView.getListView().setScaleY(s);
                filterTabsView.getListView().setTranslationX((isDrawerTransition ? AndroidUtilities.dp(4) : -AndroidUtilities.dp(4)) * (1f - slideFragmentProgress));
                filterTabsView.getListView().setPivotX(isDrawerTransition ? filterTabsView.getMeasuredWidth() : 0);
                filterTabsView.getListView().setPivotY(0);
                filterTabsView.invalidate();
            }
        }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search