【问题标题】:The text of TextView disappears (not wrapped) despite the TextView taking its appropriate size尽管 TextView 采用适当的大小,但 TextView 的文本消失(未包装)
【发布时间】:2018-06-04 00:09:19
【问题描述】:

我正在使用 ConstraintLayout(仍然是初学者)。文本视图的文本不会出现。

xml的sn-p:

    <TextView
    android:id="@+id/textView23"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:background="@color/goldenrod"
    android:lineSpacingExtra="-8.7sp"
    android:textAlignment="center"
    android:textColor="#ffffff"
    android:textSize="26.7sp"
    app:layout_constraintBottom_toBottomOf="@+id/imageView2"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    tools:text="JOIN US" />

我都试过了:

    app:layout_constraintWidth_default="wrap"
    app:layout_constrainedWidth="true"

编辑: 我还尝试使文本视图“wrap_content”和“match_parent”

编辑 2: 毕竟是我的错。使用命名空间“工具”而不是“android”

【问题讨论】:

  • 当你说“不会出现”时,你到底是什么意思? tools:text 只会在设计器视图中设置文本,而不是在运行时。您是否在运行时设置文本?发布您的完整 XML 以获得更好的外观。
  • 我不敢相信我犯了这么愚蠢的错误。谢谢。
  • 将问题标记为已回答或将其删除。

标签: java android textview android-constraintlayout


【解决方案1】:

您必须更改此参数:

android:layout_width="0dp"

试试:

android:layout_width="wrap_content"

或:

android:layout_width="match_parent"

或大于 0dp 的值。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多