比如用于聊天气泡,我希望是wrap_content,当然也不希望宽度超出约束,关键的代码是layout_constrainedWidth
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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="match_parent">
<TextView
android:id="@+id/msgL"
android:layout_width="wrap_content"