3

Hello all i need to develop layout like whats app in chatting screen like this in this i want to display time after chat textview complete.

For that i have done

<RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/blue" >

                <TextView
                    android:id="@+id/tv_message_chat_item_f"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="2dp"
                    android:layout_marginTop="2dp"
                    android:gravity="left|center"

                    android:paddingBottom="@dimen/one_dp"
                    android:paddingLeft="@dimen/fifteen_dp"
                    android:paddingRight="@dimen/five_dp"
                    android:paddingTop="@dimen/one_dp"
                      android:textAppearance="?android:attr/textAppearanceMedium"
                    android:text="fgfdgdf rete tretretret rtrtrwtw fgdfr grtwerwerewr ewrwerew" />

                <TextView
                    android:id="@+id/tv_message_time_f"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_below="@+id/tv_message_chat_item_f"
                    android:layout_marginBottom="2dp"
                   android:paddingRight="@dimen/five_dp"
                    android:gravity="right"
                    android:paddingBottom="@dimen/one_dp"
                    android:text="fgfdg"
                    android:textAppearance="?android:attr/textAppearanceSmall" />



            </RelativeLayout>

But not working with big message (the time texview not set properly)

Android
  • 8,995
  • 9
  • 67
  • 108

3 Answers3

1
<LinearLayout
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:gravity="bottom"
        android:background="@drawable/blue"
        android:layout_alignParentStart="true" android:weightSum="10">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="Hi"
            android:layout_weight="1"
            android:id="@+id/textView"
            android:gravity="bottom"
            android:layout_centerVertical="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true" />

        <TextView
            android:id="@+id/textView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="bottom"
            android:layout_marginStart="10dp"
            android:text="Small Text"
            android:textAppearance="?android:attr/textAppearanceSmall" />

    </LinearLayout>
Android
  • 8,995
  • 9
  • 67
  • 108
0

assuming your textView3 is the one with the "Big message" you should first take advantage of relative layout capabilities and use android:layout_below="@id/textview2" this will prevent overlapping with textView2 instead of just aligning everything from the bottom up.

  <TextView
                android:id="@+id/textView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/textView2"
                android:layout_centerHorizontal="true"
                android:text="Small Text"
                android:textAppearance="?android:attr/textAppearanceSmall" />

then after you set your TextView that will hold your 'time' you can once agian use something like

   <TextView
                    android:id="@+id/textView3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/textView2"
                    android:gravity="right"
                    android:layout_alignParentRight="true"
                    android:text="12:00 pm"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

Gravity right will allow the text to be place from right to left, since displaying time usually does not take more than 6 or 7 characters it will help.

Hope it resolves your problem.

Joel
  • 838
  • 5
  • 12
0

You will need to implement ImageViews using 9patches (here: link) And a listview, which can handle CustomLayouts for ListItems (with the 9Patch ImageView).

I think you are able to implement a list view, therefore I don't go deeper here. Greets.

JacksOnF1re
  • 3,336
  • 24
  • 55