android ConstraintLayout Ellipsize文本以不同的偏移量开始

时间:2019-03-26 15:15:06

标签: android android-constraintlayout android-layoutparams ellipsize

我有这个android布局

(root是约束布局)

 TextAppearance.My
    <item name="android:ellipsize">end</item>
    <item name="android:gravity">start</item>
    <item name="android:maxLines">1</item>

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

  <myImageView
      android:id="@+id/account_avatar"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginStart="@dimen/avatar_margin_start"
      android:layout_marginLeft="@dimen/avatar_margin_start"
      android:layout_marginTop="@dimen/avatar_vertical_margin"
      android:layout_marginBottom="@dimen/avatar_vertical_margin"
      android:padding="@dimen/disc_padding"
      android:contentDescription="@null"
      app:maxDiscContentSize="@dimen/image_view_size"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      tools:src="@drawable/quantum_ic_account_circle_googblue_24"/>
  <TextView
      android:id="@+id/account_display_name"
      style="@style/TextAppearance.My"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_marginStart="@dimen/avatar_margin_end"
      android:layout_marginEnd="@dimen/margin_end"
      android:layout_marginLeft="@dimen/avatar_margin_end"
      android:layout_marginRight="@dimen/margin_end"
      app:layout_constraintBottom_toTopOf="@+id/account_name"
      app:layout_constraintEnd_toStartOf="@+id/account_disabled_help_tooltip"
      app:layout_constraintStart_toEndOf="@+id/account_avatar"
      app:layout_constraintTop_toTopOf="parent"
      app:layout_constraintVertical_chainStyle="packed"
      app:layout_constraintWidth_default="wrap"
      app:layout_constraintHorizontal_bias="0"
      tools:text="DisplayNameIsLongSoItShouldBeTruncatedAtSomePoint"/>
  <TextView
      android:id="@+id/account_name"
      style="@style/TextAppearance.My"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_marginStart="@dimen/avatar_margin_end"
      android:layout_marginEnd="@dimen/margin_end"
      android:layout_marginLeft="@dimen/avatar_margin_end"
      android:layout_marginRight="@dimen/margin_end"
      android:layout_marginTop="@dimen/display_name_email_margin"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toStartOf="@+id/account_disabled_help_tooltip"
      app:layout_constraintStart_toEndOf="@+id/account_avatar"
      app:layout_constraintTop_toBottomOf="@+id/account_display_name"
      app:layout_constraintWidth_default="wrap"
      app:layout_constraintHorizontal_bias="0"
      tools:text="emailisverylongaswellwewantittogettruncated@gmail.longdomain.com"/>
  <ImageView
      android:id="@+id/account_disabled_help_tooltip"
      android:layout_width="18dp"
      android:layout_height="18dp"
      android:layout_marginTop="@dimen/help_tooltip_margin_top"
      android:layout_marginEnd="@dimen/help_tooltip_margin_end"
      android:layout_marginRight="@dimen/help_tooltip_margin_end"
      android:contentDescription="@null"
      android:visibility="gone"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      app:srcCompat="@drawable/quantum_gm_ic_help_outline_vd_theme_24"/>

</merge>

它曾经是:

具有内部线性布局(垂直)的线性布局(水平) 然后就没有问题了。

这会导致一个奇怪的错误,在该错误中,名称被省略了,并开始了不同的文本偏移。

这会导致短名称可能会省略,而长名称可能不会。

是什么原因造成的?

ellipsizelayout_width="0dp"有问题吗?

enter image description here

0 个答案:

没有答案