layout_constraintWidth_default =“包装";不建议使用其他替代方法吗? [英] layout_constraintWidth_default="wrap" is deprecated any alternative?

查看:228
本文介绍了layout_constraintWidth_default =“包装";不建议使用其他替代方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在textview中使用了这个layout_constraintWidth_default ="wrap"来保持textview内容被包裹(在它的右边有imageview),因为textview中的文本增加了,textview的面积会增大,从而将imageview移到右边.

I was using this layout_constraintWidth_default="wrap" in textview to keep the textview content wrapped(to right of it there is imageview), as the text in textview increases textview area will grow which moves the imageview to right.

layout_constraintWidth_default="wrap"

因为它已被其他替代品淘汰?

As it is deprecated any alternatives?

Logcat

推荐答案

以下是我为解决方案所做的更改,imageview不会超出可见屏幕区域:

Following are the changes i have made for solution, imageview will not go outside the visible screen area :

android:layout_width="wrap_content"
app:layout_constrainedWidth="true"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintHorizontal_chainStyle="packed"

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:id="@+id/text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Text asdasdasdasdasdasdasdasdasdadsasdasdasdasdasdasdasd"
            app:layout_constrainedWidth="true"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toStartOf="@+id/image"
            app:layout_constraintHorizontal_bias="0"
            app:layout_constraintHorizontal_chainStyle="packed"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <ImageView
            android:id="@+id/image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@mipmap/ic_launcher"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toEndOf="@+id/text"
            app:layout_constraintTop_toTopOf="parent" />

    </androidx.constraintlayout.widget.ConstraintLayout>

这篇关于layout_constraintWidth_default =“包装";不建议使用其他替代方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆