1

I have two activities with same bottom bar. The problem is when i call to startActivity from Activity A to Activity B has some blink and is not looking so smooth. for example what I want is like Activity with a container with two fragments and the activity has the bottom bar so this will not change the bottom bar.

I know Activity with Fragments can help me with that but is too complicated to change it on my project so is the last option for me.

I find one more option to do it with SharedElements transition but is supported only from api 21 (Lollipop).

enter image description here

This is my activities and I need the LinearLayout on bottom stay sticky when i change it to Activity B.

Yoni
  • 1,346
  • 3
  • 16
  • 38

5 Answers5

2

You can set up activity animations:

startActivity();
overridePendingTransition(R.anim.hold, R.anim.fade_in);

Please, refer to this answer: stackoverflow

useless dinosaur
  • 649
  • 10
  • 17
1

you can remove the defulat transtion between activites. try this under yourProject/res/values/styles.xml:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowAnimationStyle">@null</item>
</style>
0

If you want the same instance you will have to use fragments. If not you could just put that LinearLayout to both layout files. Which one do you want?

user221256
  • 415
  • 5
  • 14
0

You need create a layout and include ex. bottombar.xml in layout folder and create the layout.

 <include layout="@layout/bottombar"/>

if you dont want look delay in change you need use fragments.

To manage fragment, i recommended use FragNav

With this library manage fragments its very easy, remove animation is not solution to your problem

0

I have made an Activity with two fragments. In Activity class ,I have write this code for commonBottomSheet :-

BottomSheetBehavior mBottomSheetBehavior = BottomSheetBehavior.from(findViewById(R.id.bottom_pannel_layout));
mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
mBottomSheetBehavior.setBottomSheetCallback(mBottomSheetCallback);

In Activity xml file in Co-ordinator layout I have included below layout :-

<include layout="@layout/bottom_sheet_pannel"/>

In CommonBottomSheetFragment, you can create your layout .

And my xml file (bottom_sheet_pannel) for bottomSheet is like this :-

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/bottom_pannel_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    app:behavior_peekHeight="45dp"
    app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

    <ImageView
        android:id="@+id/grabber_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:src="@drawable/ic_vector_slider_grabber"
        android:tint="@color/colorTint" />

    <fragment
        android:id="@+id/rf_common_details_fragment"
        android:layout_marginTop="@dimen/margin_10"
        android:name="com.fragment.CommonBottomSheetFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>

you can change state of bottomSheet with below callBack :-

 private BottomSheetBehavior.BottomSheetCallback mBottomSheetCallback = new BottomSheetBehavior.BottomSheetCallback() {
    @Override
    public void onStateChanged(View bottomSheet, int newState) {
        // do what you want on state change
    }

    @Override
    public void onSlide(View bottomSheet, float slideOffset) {

    }
};
Alok Mishra
  • 1,904
  • 1
  • 17
  • 18