title: RecyclerView gravity to chat message
body: <p>I'm developing a chat app, but I can't figure out how to adjust the messages (gravity) based on the user sent/receiver.</p>
  
  <p>What I've tried:</p>
  
  <pre><code>@Override
      public void onBindViewHolder(final MessageDialogViewHolder holder, int position) {
          final QBChatMessage item = messageList.get(position);
          holder.attachEntity(item);
          holder.text.setText(item.getBody());
          holder.personName.setText(ChatService.getInstance().getDialogsUsers().get(item.getSenderId()).getFullName());
  
          LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
  
          if(item.getSenderId().equals(ChatService.getInstance().getCurrentUser().getId())){
              params.gravity = Gravity.END;
              holder.container.setGravity(Gravity.END);
          }else{
              params.gravity = Gravity.START;
              holder.container.setGravity(Gravity.START);
          }
  
          holder.container.setLayoutParams(params);
  
      }
  </code></pre>
  
  <p>My xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
      android:id="@+id/singleMessageContainer"
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="@drawable/bubble_b"
      android:orientation="vertical"&gt;
  
      &lt;ImageView
          android:id="@+id/imgMessage"
          android:layout_width="25dp"
          android:layout_height="25dp"
          android:layout_gravity="start"
          android:visibility="gone"/&gt;
  
      &lt;TextView
          android:id="@+id/personName"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="start"
          android:textSize="14sp"
          /&gt;
  
      &lt;TextView
          android:id="@+id/singleMessage"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="start"
          android:layout_margin="5dip"
          android:paddingLeft="10dip"
          android:text=""
          android:textColor="@android:color/primary_text_light"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>What am I missing here ?</p>
  
  <p>Thanks for your time, any help is appreciated !</p>