Android: set gravity of RecyclerView's items
<p>I have a recyclerView that behaves like a list, when I delete an item, all the others go up, I want them to go down instead. I'm thinking about setting gravity to the items, or inverting the positions in the adapter, making the bottom position 0.</p>

<p><strong>My adapter (custom):</strong></p>

<pre><code>public class AddEventsAdapter extends HFRecyclerViewAdapter&lt;String, AddEventsAdapter.ViewHolder&gt; {

    public AddEventsAdapter(Context context) {
        super(context);
    }

    @Override
    public void footerOnVisibleItem() {

    }

    @Override
    public void addData(int position, String item) {
        super.addData(position, item);
    }

    @Override
    public ViewHolder onCreateDataItemViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.data_item, parent, false);
        return new ViewHolder(v);
    }

    @Override
    public void onBindDataItemViewHolder(ViewHolder holder, int position) {
        holder.itemTv.setText(getData().get(position));
    }

    class ViewHolder extends RecyclerView.ViewHolder{
        TextView itemTv;
        LinearLayout theLayout;
        public ViewHolder(View itemView) {
            super(itemView);
            itemTv = (TextView)itemView.findViewById(R.id.itemTv);
            theLayout = (LinearLayout)itemView.findViewById(R.id.layout2);
            theLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    removeData(getAdapterPosition());
                }
            });
        }
    }
}
</code></pre>

<p><strong>Implementation:</strong></p>

<pre><code>    AddEventsAdapter myAdapter = new AddEventsAdapter(this);
    assert layout != null;
    layout.setAdapter(myAdapter);

    layout.setLayoutManager(new LinearLayoutManager(this));

    View footerView = LayoutInflater.from(this).inflate(R.layout.footer, layout, false);
    myAdapter.setFooterView(footerView);

    ArrayList&lt;String&gt; data = new ArrayList&lt;&gt;();
    for (int i=0; i&lt;8; i++){
        data.add(String.format("Item %d", i));
    }
    myAdapter.setData(data);
</code></pre>