title: How to left and right align android chat app like in whatsapp
body: <p>I am following a tuturiol on youtube to create a chat app. The problem i am facing is that i do not seem to get the chats to be displayed the way whatsapp does, like the sender's should be at the right and the user's at the right. I tried a couple of methods using if else statements seem to align to one side. Here are my codes. And it is not like other questions as i have 2 different xmls and im trying to use java</p>
  
  <p>chat_item_left.xml</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      xmlns:app="http://schemas.android.com/apk/res-auto"&gt;
  
  &lt;com.github.library.bubbleview.BubbleTextView
      android:layout_alignParentStart="true"
      android:layout_marginTop="5dp"
      android:layout_below="@id/messageUser"
      android:textAppearance="@style/TextAppearance.AppCompat.Body1"
      android:textColor="#FFF"
      android:textSize="18sp"
      android:id="@+id/messageText"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:padding="10dp"
      app:arrowWidth="8dp"
      app:angle="8dp"
      app:arrowHeight="10dp"
      app:arrowPosition="14dp"
      app:arrowLocation="left"
      app:bubbleColor="#333639"
      app:arrowCenter="true"
      android:text="hie"
      android:layout_alignParentLeft="true" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>chat_item_right.xml</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      xmlns:app="http://schemas.android.com/apk/res-auto"&gt;
  
     &lt;RelativeLayout
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"&gt;
  
         &lt;com.github.library.bubbleview.BubbleTextView
             android:layout_alignParentEnd="true"
             android:layout_marginTop="5dp"
             android:textAppearance="@style/TextAppearance.AppCompat.Body1"
             android:textColor="#FFF"
             android:textSize="18sp"
             android:id="@+id/messageText"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:padding="10dp"
             app:arrowWidth="8dp"
             app:angle="8dp"
             app:arrowHeight="10dp"
             app:arrowPosition="14dp"
             app:arrowLocation="right"
             app:bubbleColor="@android:color/holo_blue_bright"
             app:arrowCenter="true"
             android:text="hie"
             android:layout_alignParentRight="true" /&gt;
  </code></pre>
  
  <p></p>
  
  <p></p>
  
  <p>And here is what i have done with my code so far</p>
  
  <pre><code> private void displayChatMessage() {
      ListView listOfMessage = (ListView) findViewById(R.id.listOfMessage);
      Query query = FirebaseDatabase.getInstance().getReference().child("chats");
  
      FirebaseListOptions&lt;ChatMessage&gt; options = new FirebaseListOptions.Builder&lt;ChatMessage&gt;()
              .setLayout(R.layout.chat_item_left)
              .setQuery(query, ChatMessage.class)
              .build();
  
      adapter = new FirebaseListAdapter&lt;ChatMessage&gt;(options) {
          @Override
          protected void populateView(View v, ChatMessage model, int position) {
              // Bind the Chat to the view
              // ...
              //get references to views of list_item.xml
              TextView messageText ,messageUser,messageTime;
              messageText = (BubbleTextView) v.findViewById(R.id.messageText);
  
  
              messageText.setText(model.getMessageText());
  
          }
      };
      listOfMessage.setAdapter(adapter);
  }
  </code></pre>
  
  <p>Where do i specify to put the right alignemnt?</p>