textView lines - advice

▼魔方 西西 提交于 2019-12-02 11:42:59

The best and easiest way is to set the name to stay at the left of the second image.

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_marginLeft="10dp"
    android:adjustViewBounds="true"
    android:src="@drawable/icon" />

<ImageView
    android:id="@+id/imageView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentright="true"
    android:layout_marginRight="10dp"
    android:adjustViewBounds="true"
    android:src="@drawable/icon" />

<TextView
    android:id="@+id/fullnameTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toLeftOf="@+id/imageView2"
    android:layout_toRightOf="+@id/wayimageView"
    android:textColor="@color/list_text_color"
    android:textSize="16dp" />

You can bound the max width of your TextView:

android:maxWidth="10dp"

Give the size of textview like android:layout_width="xdp" and android:maxLines="2" or whatever you want.

You can make use of this

    android:ellipsize="end" 
    android:maxLines="1"
    android:scrollHorizontally="true"

If your text goes out of textview's width then "..." dots will be appended at the end.

If above code not working add android:singleLine="true"

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!