У меня есть этот xml-макет для Android, который выглядит так, и, как вы видите, у него есть чаты. Я хотел преобразовать его с LinearLayout
в ConstraintLayout
.
Это LinearLayout
версия, и это выглядит нормальноКак создать чат-создание пузырей в ConstraintLayout
Это ConstraintLayout
версия и чат Bubbels выглядят не так красиво.
Я хочу некоторую помощь с этим пузыри. Стрелка, как вы видите, трудно сдержать, чтобы она выглядела хорошо. Я добавил один android.support.constraint.Guideline
, чтобы сделать некоторые ограничения, но не работает.
Вот ConstraintLayout
XML
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end|center_vertical">
<com.github.curioustechizen.ago.RelativeTimeTextView
android:id="@+id/timestamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?AppTheme.ChatBubbleTextColor"
android:textSize="@dimen/chat_timestamp_text_size"
tools:text="Just Now"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"
app:layout_constraintRight_toLeftOf="@+id/message"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp" />
<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_balloon"
android:padding="8dp"
android:textColor="?AppTheme.ChatBubbleTextColor"
android:textSize="@dimen/chat_message_body_text_size"
tools:text="This is chat message"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toLeftOf="@+id/guideline1"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" />
<android.support.constraint.Guideline
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/guideline1"
android:orientation="vertical"
tools:layout_editor_absoluteY="0dp"
tools:layout_editor_absoluteX="218dp"
app:layout_constraintGuide_percent="0.859375" />
<View
android:layout_width="8dp"
android:layout_height="8dp"
android:background="?AppTheme.ChatBubbleBackGroundColor"
android:rotation="45"
android:id="@+id/view"
app:layout_constraintRight_toLeftOf="@+id/thumbnail"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="@+id/guideline1"
app:layout_constraintHorizontal_bias="0.0"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp" />
<ImageView
android:id="@+id/thumbnail"
android:layout_width="22dp"
android:layout_height="24dp"
tools:src="@drawable/tw__composer_logo_blue"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginRight="8dp" />
</android.support.constraint.ConstraintLayout>
Может быть, есть какая-то библиотека на GitHub, что создает пузыри или какие-либо идеи по этому поводу было бы здорово?