Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextView didn't ellipsize with layout_constraintWidth_max and layout_constraintHeight_max #131

Open
skauss opened this issue Feb 9, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@skauss
Copy link

skauss commented Feb 9, 2021

Hi
I need a TextView with max width and height. In case the text is to long I expect dotted at the end (ellipsize="end").
This didn't work.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".SecondFragment">

<TextView
        android:id="@+id/textview_second"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ellipsize="end"

        android:text="Text sf asd fasd fas dfasd fasd fasd fas dfas dfas dfg sdfg sdfg  sdfgs fdg sdfa sdfas dfa sdfa sdfa fsaas dfas dfa sdfasd fa sdf asdf asdfasdf "

        android:maxWidth="100dp"
        android:maxHeight="100dp"
        app:layout_constraintWidth_max="100dp"
        app:layout_constraintHeight_max="100dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

Removing maxWidth and maxHeight didn't help.

Bildschirmfoto 2021-02-09 um 08 37 10

Regards
Stephan

@skauss skauss added the bug Something isn't working label Feb 9, 2021
@jafu888
Copy link
Collaborator

jafu888 commented Feb 9, 2021

ConstraintLayout does not control the contentment of children views. It only constrains the position of views.
Research ellipsis of multiline textView for a solution.

@camaelon camaelon self-assigned this Feb 26, 2021
@Hpbbs
Copy link

Hpbbs commented Feb 25, 2022

I encounter this situation too, i solved, but i dont know why that help
In addition background follows:

<ImageButton
        android:id="@+id/fragment_dshell_state"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintWidth_max="350dp"
        app:layout_constraintWidth_percent="@dimen/status_width_percent"
        app:layout_constraintDimensionRatio="1"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.38" />

    <com.didi.it.dday.ui.widget.SelfOnDrawView
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:gravity="center"
        android:padding="0dp"
        app:layout_constraintWidth_max="330dp"
        app:layout_constraintWidth_percent="0.54"
        app:layout_constraintBottom_toBottomOf="@+id/fragment_dshell_state"
        app:layout_constraintEnd_toEndOf="@+id/fragment_dshell_state"
        app:layout_constraintStart_toStartOf="@+id/fragment_dshell_state"
        app:layout_constraintTop_toTopOf="@+id/fragment_dshell_state"
        app:backWidth="7dp"
        app:backColor="#F6F6F9"
        app:progFirstColor="#FF0027EC"
        app:progStartColor="#FF6E9DFF"
        app:progWidth="7dp" />

if put SelfOnDrawView above(means write xml before) ImageButton, the app:layout_constraintWidth_max attr will not efficient

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants