There is a DrawerLayout . I select the menu item on it and a fragment opens. I need a transition (animation). Here is the fragment code:
public class RulesFragment extends Fragment { private View myView; private static final String TAG = "myLogs"; @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); getActivity().overridePendingTransition(R.anim.trans_left_in, R.anim.trans_left_out); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { myView = inflater.inflate(R.layout.fragment_rules, container, false); Log.d(TAG, "RulesFragment"); getActivity().setTitle(R.string.nav_rules); return myView; } }
Here is the fragment markup:
<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="@string/rules_title_text" android:textColor="?attr/editTextColor" android:textSize="@dimen/size_textview_phrase" android:textStyle="bold" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/rules_text" android:textColor="?attr/editTextColor" android:textSize="@dimen/size_textview_phrase" android:textStyle="normal" /> </LinearLayout> </android.support.v4.widget.NestedScrollView> Please suggest what the problem is. Thank you in advance!
fTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);it seems to work (although not very noticeably), but the second option does not passfTransaction.setCustomAnimations(R.animator.slide_in_left, R.animator.slide_in_right);underlines in red. Although in any case they pushed me to search, according to other criteria. So your answer needs to be made an “answer”) - Maxim Fomichev