Shimmer动画在滚动时在RecyclerView内停止

时间:2018-03-31 16:22:47

标签: java android android-recyclerview android-animation

Shimmer在我的项目中就像一个魅力,但有一点问题。因为我在我的recyclerview中使用微光,当我滚动时它会停止动画:(

该问题的简单视频 - > Video_Of_Stopping Shimmer [20 Sec]

注意:我在嵌套的recyclerview中应用了微光。 这是我的片段(为简单起见,我只添加了有意义的代码)。

在MyAdapter内部

    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
......................................
 switch (holder.getItemViewType()) {
 case ViewType.LATEST_MOVIE:
                final LatestMovieViewHolder latestMovieViewHolder = (LatestMovieViewHolder) holder;
                latestMovieViewHolder.titleMovie.setText("Latest Movie");
                latestMovieViewHolder.shimmerFrameLayout.setVisibility(View.VISIBLE);
                latestMovieViewHolder.shimmerFrameLayout.startShimmerAnimation();
                latestMovieViewHolder.sectionRecylerView.setLayoutManager(new LinearLayoutManager(context, OrientationHelper.HORIZONTAL, false));
                latestMovieViewHolder.sectionRecylerView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
                RetrofitRequestAPI retrofitRequestAPI = MyRetrofit.getRetrofitInstance().create(RetrofitRequestAPI.class);
                Call<List<Movie>> requestObject = retrofitRequestAPI.getMoviesInTheater();
                requestObject.enqueue(new Callback<List<Movie>>() {
                    @Override
                    public void onResponse(Call<List<Movie>> call, Response<List<Movie>> response) {
                        if (response.body() != null) {
                            latestMovieViewHolder.shimmerFrameLayout.stopShimmerAnimation();
                            latestMovieViewHolder.sectionRecylerView.setVisibility(View.VISIBLE);
                            latestMovieViewHolder.shimmerFrameLayout.setVisibility(View.GONE);
                            latestMovieViewHolder.sectionRecylerView.setAdapter(new SectionAdapter(context, response.body()));
                        }
                    }

                    @Override
                    public void onFailure(Call<List<Movie>> call, Throwable t) {
                        Toast.makeText(context, t.getMessage(), Toast.LENGTH_LONG).show();
                    }
                });
                break;

1 个答案:

答案 0 :(得分:1)

它的库问题:

Shimmer Issue 42