Recyclerview анимация не работает в деятельности - PullRequest
0 голосов
/ 13 апреля 2020

у меня есть действие, которое содержит 2 фрагмента

StepsFragment содержит Recyclerview, но анимация Recyclerview не работает

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="400dp"
    android:background="#B3D1DB"
    tools:context=".StepsFragment">

    <TextView
        android:id="@+id/inputEntred"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView"
        android:visibility="invisible" />

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/RV"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        android:layoutAnimation="@anim/layou_animation_fall_down"
        android:paddingTop="10dp"
        android:paddingBottom="30dp" />
</RelativeLayout>

layou-animation-fall-down

    <layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
        android:animation="@anim/fall_down"
         android:animationOrder="normal"
           android:delay="15%">

падение

   <set xmlns:android="http://schemas.android.com/apk/res/android" android:duration="6000">
        <translate
            android:fromYDelta="-20%"
            android:interpolator="@android:anim/accelerate_decelerate_interpolator"
            android:toYDelta="0"
            android:duration="1000" />
     <alpha
     android:fromAlpha="0"
     android:interpolator="@android:anim/accelerate_decelerate_interpolator"
     android:toAlpha="3"
         android:duration="1000"
     />
  <scale
      android:fromXScale="105%"
      android:fromYScale="105%"
      android:interpolator="@android:anim/accelerate_decelerate_interpolator"
      android:pivotX="50%"
      android:pivotY="50%"
      android:toXScale="100%"
      android:toYScale="100%" android:duration="1000"
      />
</set>

макет деятельности

<androidx.constraintlayout.widget.ConstraintLayout 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"
tools:context=".Sorting_activity">


<RelativeLayout
    android:id="@+id/triLayout"
    android:layout_width="0dp"
    android:layout_height="300dp"
    app:layout_constraintBottom_toTopOf="@+id/stepsLayout"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.0">

</RelativeLayout>

<androidx.coordinatorlayout.widget.CoordinatorLayout
    android:id="@+id/stepsLayout"
    android:layout_width="0dp"
    android:layout_height="0dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/triLayout"></androidx.coordinatorlayout.widget.CoordinatorLayout>

StepsFragment

 public class StepsFragment extends Fragment  {


private OnFragmentInteractionListener mListener;

private static TextView inputEntred  ;
private static RecyclerView RV ;
private Handler mhandler = new Handler();


public StepsFragment() {
    // Required empty public constructor
}

public void setTextView(String textentered){
    inputEntred.setText(textentered);
    String[] numberList = inputEntred.getText().toString().split(",");
    final Integer[] numbers = new Integer[numberList.length];
    SelectionSort m1 = new SelectionSort();
   ArrayList<String> mystepsList = m1.steps(numbers);// returns the steps numbers
    final StepListAdapter adapter = new StepListAdapter() ;
    RV.setAdapter(adapter);

    LinearLayoutManager llm = new LinearLayoutManager(getActivity());
    RV.setLayoutManager(llm);

        adapter.setList(mystepsList);

}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

     View view =inflater.inflate(R.layout.fragment_steps, container, false);
      inputEntred  =view.findViewById(R.id.inputEntred);
       RV =view.findViewById(R.id.RV);

    return view;
}

@Override
public void onAttach(Context context) {
    super.onAttach(context);
    if (context instanceof OnFragmentInteractionListener) {
        //   mListener = (OnFragmentInteractionListener) context;
    } else {
        throw new RuntimeException(context.toString()
                + " must implement OnFragmentInteractionListener");
    }
}
public interface OnFragmentInteractionListener {
    // TODO: Update argument type and name
    void onFragmentInteraction(Uri uri);
}}

1 Ответ

0 голосов
/ 13 апреля 2020

Не могли бы вы попробовать это? Я должен удалить ненужную продолжительность в XML. Спасибо

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="250">

    <translate
        android:fromYDelta="-20%"
        android:toYDelta="0"
        android:interpolator="@android:anim/decelerate_interpolator"
        />

    <alpha
        android:fromAlpha="0"
        android:toAlpha="1"
        android:interpolator="@android:anim/decelerate_interpolator"
        />

    <scale
        android:fromXScale="105%"
        android:fromYScale="105%"
        android:toXScale="100%"
        android:toYScale="100%"
        android:pivotX="50%"
        android:pivotY="50%"
        android:interpolator="@android:anim/decelerate_interpolator"
        />

</set>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...