文本视图未与约束布局中的准则对齐

文本视图未与约束布局中的准则对齐,第1张

概述我有以下约束布局:`<?xmlversion="1.0"encoding="utf-8"?><android.support.v7.widget.CardViewxmlns:android="http://schemas.android.com/apkes/android"xmlns:card_view="http://schemas.android.com/apkes-auto&quot

我有以下约束布局

`<?xml version="1.0" enCoding="utf-8"?><androID.support.v7.Widget.CardVIEw xmlns:androID="http://schemas.androID.com/apk/res/androID"    xmlns:card_vIEw="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:layout_margin="16dp">    <androID.support.constraint.ConstraintLayout xmlns:app="http://schemas.androID.com/apk/res-auto"        androID:layout_wIDth="match_parent"        androID:layout_height="match_parent">        <androID.support.constraint.GuIDeline            androID:ID="@+ID/vertical_guIDeline"            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:orIEntation="vertical"            app:layout_constraintGuIDe_percent="0.6" />        <TextVIEw            androID:ID="@+ID/date_tv"            androID:layout_wIDth="wrap_content"            androID:layout_height="16dp"            androID:layout_marginleft="8dp"            androID:layout_margintop="16dp"            app:layout_constraintleft_toleftOf="parent"            app:layout_constrainttop_totopOf="parent"            tools:text="2 hours ago" />        <TextVIEw            androID:ID="@+ID/source_tv"            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:layout_marginleft="8dp"            androID:textStyle="bold"            app:layout_constraintleft_toRightOf="@ID/date_tv"            app:layout_constrainttop_totopOf="@ID/date_tv"            tools:text="BBC News" />        <TextVIEw            androID:ID="@+ID/headline_tv"            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:layout_marginleft="8dp"            androID:layout_margintop="32dp"            androID:maxlines="2"            androID:textStyle="bold"            app:layout_constraintleft_toleftOf="parent"            app:layout_constrainttop_toBottomOf="@ID/date_tv"            app:layout_constraintRight_toleftOf="@ID/vertical_guIDeline"            tools:text="Apple admits slowing down older iphones" />    </androID.support.constraint.ConstraintLayout></androID.support.v7.Widget.CardVIEw>`

它具有以下输出:

现在,我想要的是标题文本视图应仅与准则一样宽,并且在文本较长时应移至下一行.这没有发生.有人可以帮我这个忙吗?

解决方法:

尝试将宽度设置为0dp(match_constraints),如下所示:

    <TextVIEw        androID:ID="@+ID/headline_tv"        androID:layout_wIDth="0dp"        androID:layout_height="wrap_content"        androID:layout_marginleft="8dp"        androID:layout_margintop="32dp"        androID:maxlines="2"        androID:textStyle="bold"        app:layout_constraintleft_toleftOf="parent"        app:layout_constrainttop_toBottomOf="@ID/date_tv"        app:layout_constraintRight_toleftOf="@ID/vertical_guIDeline"        tools:text="Apple admits slowing down older iphones" />
总结

以上是内存溢出为你收集整理的文本视图未与约束布局中的准则对齐全部内容,希望文章能够帮你解决文本视图未与约束布局中的准则对齐所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1081013.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-27
下一篇2022-05-27

发表评论

登录后才能评论

评论列表(0条)

    保存