Reputation: 336
I am trying to make an application like UBER and I have completed it to some extant but the problem I am facing is that on main screen when pickUp location animation is shown, an animation is implement that lift whole screen Up and down. I tried a lot to do this but I am not getting any idea. So please can anybody tell me how can I achieve this animation. I am uploading a .gif image for getting the idea
Upvotes: 4
Views: 4762
Reputation: 1
The layout can be shown like this:
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();
}
Upvotes: 0
Reputation: 1899
Set BottomSheetBehaviour class as the layout_behavior of the desired view.
Put the below view inside a layout that has CoordinatorLayout as the root.
Example :
<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>
In your activity, initalise the BottomSheetDialog as :
final View bottomSheet = view.findViewById(R.id.bottom_sheet);
behavior = BottomSheetBehavior.from(bottomSheet);
To open the BottomSheet, add the following code in the onClickListener of your desired widget.
behaviorProfile.setState(BottomSheetBehavior.STATE_EXPANDED);
Upvotes: 1
Reputation: 139
layout/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>
values/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>
1)Import design library in android studio (version may differ) compile 'com.android.support:appcompat-v7:22.1.1'
Upvotes: 0
Reputation: 3456
You have to handle scrolls with CoordinatorLayout and use a CollapsingToolbarLayout of Design Support Library.
This two examples may help you :
Handling Scrolls with CoordinatorLayout
Upvotes: 3