0

Developing an application in which there is a recyclerview with some cardsviews. On each card there are some images,textviews and relative layout that I would like to apply a facebook-like effect when touched.

Facebook reactions

  • When you touch the screen, the card will expand, and the others will stay side by side at their original size.
  • When you take your finger off the screen, the card will return to its original size.

What I have so far:

//rv
        recyclerView = view.findViewById(R.id.recyclerView)

        recyclerView.setHasFixedSize(false)
        //layoutManager = LinearLayoutManager(activity)

        recyclerView.layoutManager = LinearLayoutManager(activity, LinearLayoutManager.VERTICAL, false)

Adapter:

public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {

    Context context;
    List<Content> lista;


    public MyAdapter(Context context, List<Content> lista) {
        this.context = context;
        this.lista = lista;
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder myViewHolder, int position) {
        Content content = lista.get(position);

        if (!content.getTitulo().isEmpty()) {
            myViewHolder.titulo.setText(content.getTitulo);
        }

        if (!noticia.getThumb().isEmpty()) {
            Glide.with(context).load(content.getThumb()).into(myViewHolder.imageThumb);
        }

        if (!content.getIcone().isEmpty()) {
            Glide.with(context).load(content.getIcone()).into(myViewHolder.icone);
        }

        if (!content.getDescricao().isEmpty()) {
            myViewHolder.textDescricao.setText(content.getDescricao());
        }

        if (!content.getData().isEmpty()) {
            myViewHolder.data.setText(content.getData());
        }

        if (!content.getUrl().isEmpty()) {
            myViewHolder.url = content.getUrl();
        }

        if (!content.getNomeSite().isEmpty()) {


            myViewHolder.nomeSite.setText(content.getNomeSite());
        }

        myViewHolder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                Toast.makeText(context,"OnLongClick",Toast.LENGTH_SHORT).show();
                return false;
            }
        });

    }

How can I make this effect?

  • Did you actually make that effect? The one in the link you provided. If so, could you share source code. I am looking to develop the same behavior but not able to start off – musooff Sep 17 '19 at 00:26

1 Answers1

0

I think you could use a library for that. Here are some of them:

Carousel Recyclerview

Carousel Recyclerview 2

Or you can use this this answer

Pehr Sibusiso
  • 862
  • 1
  • 14
  • 27