2017-09-18 52 views
-2

如何獲得旁邊的狀態消息(SEND),聊天消息可以擴大或縮小的消息長度的基礎,但在旁邊的文字聊天消息應該出現在聊天消息的文本,如何獲取聊天消息旁邊的文本?

圖片:https://ibb.co/dsZntk 圖片2:https://ibb.co/fExwm5

就像圖像顯示在右側發送文字,這就是我想達到什麼

編輯:看到圖像中的兩個時,我吹氣第二佈局狀態發送出現在固定的地方,我希望文字(發送)出現在聊天消息旁邊,如圖1

+0

你能詳細說一下嗎?我不確定你的意思。也許發佈一個樣機圖片或一些你已經嘗試過的代碼? – swerly

+0

是的,先生,我已更新我的問題 – user8515823

+0

你必須在開發時表達你的問題/問題。你正在尋求發展的幫助。爲發件人和收件人創建一個'recylerview'列表和兩個佈局視圖。只需對發送者和接收者的視圖充氣。 –

回答

0

如何讓旁邊的狀態消息(SEND),聊天消息可以擴大或縮小的消息長度的基礎,但在旁邊的文字聊天消息應該出現在聊天消息的文本,

我已經添加了一個示例xml供你參考,它會給你一個提示,你可能如何實現Views。您可以複製並粘貼Android-Studio以下的源代碼並理解設計。

<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:paddingTop="8dp"> 

<TextView 
    android:id="@+id/sendMsg" 
    android:text="This is sent msg!" 
    android:background="@color/colorPrimaryDark" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:maxWidth="240dp" 
    android:padding="8dp" 
    android:textColor="#ffffff" 
    android:layout_marginRight="8dp" 
    app:layout_constraintRight_toRightOf="parent" 
    app:layout_constraintTop_toTopOf="parent" /> 

<TextView 
    android:id="@+id/textMsgStatus" 
    android:text="Sent" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textSize="10sp" 
    android:layout_marginRight="4dp" 
    app:layout_editor_absoluteY="10dp" 
    app:layout_constraintRight_toLeftOf="@+id/sendMsg" /> 

PS:問問題在此之前,試圖通過自做律研究。這將幫助你在長期來看:)

+0

是的,我創建了兩個佈局和充氣,但我無法獲得聊天消息旁邊的文本看到我已經更新了我的問題(見圖2) – user8515823

+0

你是如何使用上面的XML? – Anurag

+0

是的,我創建了兩個XML文件,分別爲left.xml(帶有LinearLayout的1TextView)和right.xml(2個TextView帶有相對較多的)和一個list.xml,然後我使用自定義適配器將消息充氣到左邊的listview消息)和正確的(發送消息) – user8515823

0

這是一個簡單的工作,我只是做我自己複雜

我只需要使用

機器人:layout_toleftof =「聊天messaage」 然後,它會自動對齊每個聊天信息左側