为什么android:ellipsize =“ end”无法正常工作?

时间:2019-07-23 14:50:02

标签: android

我不知道为什么ellipsize="end"不起作用。 我希望这三个点出现在红色圆圈所在的位置。 我已经添加了XML代码和XML的Android Studio预览中的图像:

以防万一,我已经尝试使用:

singleLine=true 
maxLength=1 (although i dont want it - for the check) 
maxLines=x  (although i dont want it - for the check) 
layout_height=60dp  (for checking dixed size)

preview on studio

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

    <androidx.constraintlayout.widget.Guideline
            android:id="@+id/startGuideline"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintGuide_percent="0.08"/>

    <androidx.constraintlayout.widget.Guideline
            android:id="@+id/endGuideline"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintGuide_percent="0.92"/>

    <androidx.appcompat.widget.AppCompatImageView
            android:id="@+id/backgroundImage"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:adjustViewBounds="true"
            android:background="@color/transparent"
            android:scaleType="fitCenter"
            tools:src="@drawable/broken_image"
            app:layout_constraintBottom_toTopOf="@id/cornersBG"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="1"/>

    <LinearLayout
            android:id="@+id/cornersBG"
            android:layout_width="0dp"
            android:layout_height="0dp"
            app:layout_constraintHeight_percent="0.41"
            android:orientation="vertical"
            android:background="@drawable/corener_radius_rectangle_blackbalue900"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toStartOf="@id/startGuideline"
            app:layout_constraintEnd_toEndOf="@id/endGuideline">

        <androidx.appcompat.widget.AppCompatTextView
                android:id="@+id/title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                tools:text="ROOKIE"
                android:textAppearance="@style/MontserratFont.XXL.ExtraBold"
                android:maxLines="1"
                android:ellipsize="end"
                android:layout_marginTop="15dp"
                android:layout_marginStart="20dp"
                android:layout_marginEnd="20dp"/>

        <androidx.appcompat.widget.AppCompatTextView
                android:id="@+id/descriptionText"
                android:layout_width="wrap_content"
                android:layout_height="0dp"
                android:layout_weight="1"
                tools:text="מילים מילים מילים מילים מילים מילים מילים מילים מילים מילים מילים מילים מילים מימילים מילים מילים מילים מילים מילים מילים מימילים מילים מילים מילים מילים מילים מילים מימילים מילים מילים מילים מילים מילים מילים מימילים מילים מילים מילים מילים מילים מילים מימילים מילים מילים מילים מילים מילים מיליםמילים מילימיליםמילים מילימיליםמילים מילימילים ם מילים ם "
                android:ellipsize="end"
                android:textAppearance="@style/AssistantFont.M"
                android:layout_marginTop="10dp"
                android:layout_marginStart="20dp"
                android:layout_marginEnd="20dp"/>

        <androidx.appcompat.widget.AppCompatButton
                android:id="@+id/beginBtn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/begin"
                android:textAppearance="@style/AssistantFont.M.Bold"
                android:layout_marginTop="15dp"
                android:layout_marginStart="20dp"
                android:layout_marginBottom="20dp"/>
    </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

1 个答案:

答案 0 :(得分:0)

尝试使用wrap_content而不是0dp(匹配约束布局)。

像这样:

android:id="@+id/descriptionText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
相关问题