How to implement animation as the main UBER screen in Android?

I am trying to make an application like UBER, and I have completed it to some extent, but the problem I am facing is that on the main screen when the pickUp animation is displayed, the animation is implemented, which raises the whole screen up and down. I have done a lot for this, but I have no idea. So please someone tell me how I can achieve this animation. I upload a .gif image to get an ideaWholescreen green animation

+4
source share
4 answers

You need to handle the scrolls using CoordinatorLayout and use the CollapsingToolbarLayout support library.

These two examples may help you:

CoordinatorLayout

+3

BottomSheetBehaviour layout_behavior .
Layout . :

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:keepScreenOn="true"
        android:orientation="vertical"
        android:gravity="center"
        android:id="@+id/bottom_sheet"
        android:clickable="true"
        app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

<!--Add your child views.-->

</LinearLayout>

initalise BottomSheetDialog :

final View bottomSheet = view.findViewById(R.id.bottom_sheet);
behavior = BottomSheetBehavior.from(bottomSheet); 

BottomSheet, onClickListener .

behaviorProfile.setState(BottomSheetBehavior.STATE_EXPANDED);
+1

/main.xml

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

<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/background_light"
    android:fitsSystemWindows="true"
    >

    <android.support.design.widget.AppBarLayout
        android:id="@+id/main.appbar"
        android:layout_width="match_parent"
        android:layout_height="64dp"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:fitsSystemWindows="true"
        >

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/main.collapsing"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|enterAlways"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleMarginStart="64dp"
            app:expandedTitleMarginEnd="64dp"
            >

            <android.support.v7.widget.Toolbar
                android:id="@+id/main.toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:layout_collapseMode="parallax"
                />
        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>



    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        >

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="72sp"
            android:lineSpacingExtra="8dp"
            android:text="@string/lotsOfText"
            android:padding="@dimen/activity_horizontal_margin"
            />

        <!--PUT VIEWs HERE-->
    </android.support.v4.widget.NestedScrollView>

</android.support.design.widget.CoordinatorLayout>
Hide result

/styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>
Hide result

1) android ( ) 'com.android.support:appcompat-v7:22.1.1'

0

:

private void showViews() {
    ll_toolBar.animate().translationY(0).setInterpolator(new DecelerateInterpolator (2));
    cardview.animate().translationY(0).setInterpolator(new DecelerateInterpolator (2));
    ll_selectTime.animate().translationY(0).setInterpolator(new AccelerateInterpolator (2));
    fl_carsCategory.animate().translationY(0).setInterpolator(new AccelerateInterpolator(2)).start();
}
0

Source: https://habr.com/ru/post/1624928/


All Articles