0
我有这样的Android XML布局,看起来像这样,当你看到它聊天气泡。我想把它从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的一些库,创建这个气泡或任何想法将是巨大的?