相关疑难解决方法(0)

ConstraintLayout内的Wrap_content视图在屏幕外伸展

我正在尝试使用一个简单的聊天气泡ConstraintLayout.这就是我想要实现的目标:

在此输入图像描述 在此输入图像描述

但是,wrap_content似乎没有与约束一起正常工作.它尊重边距,但不能正确计算可用空间.这是我的布局:

<?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">

    <TextView
        android:id="@+id/chat_message"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="16dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintHorizontal_bias="0"
        tools:background="@drawable/chat_message_bubble"
        tools:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sodales accumsan tortor at bibendum."
        android:layout_marginStart="64dp"
        android:layout_marginLeft="64dp"
        android:layout_marginEnd="32dp"
        android:layout_marginRight="32dp"
        android:layout_marginTop="8dp"
        android:layout_marginBottom="8dp" />
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

这呈现如下:

在此输入图像描述

我在用com.android.support.constraint:constraint-layout:1.0.0-beta4.

难道我做错了什么?这是一个错误还是一个不直观的行为?ConstraintLayout我可以使用(我知道我可以使用其他布局,我ConstrainLayout具体询问)来实现正确的行为.

android android-layout android-constraintlayout

107
推荐指数
5
解决办法
4万
查看次数