ConstraintLayout中的TextView剪辑文本

时间:2016-09-02 07:44:02

标签: android android-layout textview android-constraintlayout

我在ConstraintLayout中遇到了TextView的奇怪行为。

TextView剪切文本。 在屏幕截图中,您会看到三个选择:

  1. TextView的宽度=" match_parent" - 正确的边界,但文字被剪裁;

  2. TextView的宽度=" wrap_content" - 再次剪裁不正确的边界和文本;

  3. LinearLayout中的TextView - 这是它应该如何的例子。

  4. enter image description here

    ConstraintLayout,你怎么了?

    这是我的XML布局。

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#727272"
        android:orientation="vertical"
        android:padding="16dp">
    
        <android.support.constraint.ConstraintLayout
            android:id="@+id/block"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#ffffff"
            android:padding="16dp">
    
            <ImageView
                android:id="@+id/img"
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:background="#000000"
                app:layout_constraintLeft_toLeftOf="@+id/block"
                app:layout_constraintTop_toTopOf="@+id/block" />
    
            <TextView
                android:id="@+id/text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="16dp"
                android:background="#cccccc"
                android:padding="6dp"
                android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
                app:layout_constraintLeft_toRightOf="@+id/img"
                app:layout_constraintRight_toRightOf="@+id/block"
                app:layout_constraintTop_toTopOf="@+id/img" />
    
        </android.support.constraint.ConstraintLayout>
    
        <android.support.constraint.ConstraintLayout
            android:id="@+id/block2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#ffffff"
            android:padding="16dp">
    
            <ImageView
                android:id="@+id/img2"
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:background="#000000"
                app:layout_constraintLeft_toLeftOf="@+id/block2"
                app:layout_constraintTop_toTopOf="@+id/block2" />
    
            <TextView
                android:id="@+id/text2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="16dp"
                android:background="#cccccc"
                android:padding="6dp"
                android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
                app:layout_constraintLeft_toRightOf="@+id/img2"
                app:layout_constraintRight_toRightOf="@+id/block2"
                app:layout_constraintTop_toTopOf="@+id/img2" />
    
        </android.support.constraint.ConstraintLayout>
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#ffffff"
            android:orientation="horizontal"
            android:padding="16dp">
    
            <ImageView
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:background="#000000" />
    
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="16dp"
                android:background="#cccccc"
                android:padding="6dp"
                android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat." />
    
        </LinearLayout>
    

1 个答案:

答案 0 :(得分:1)

好吧,它已知的错误和Google承诺的

  

发布于alpha 5

https://code.google.com/p/android/issues/detail?id=215537