Android TextView动态大小以椭圆化
是否可以省略文本视图而不设置maxLineAndroid TextView动态大小以椭圆化,android,android-layout,textview,Android,Android Layout,Textview,是否可以省略文本视图而不设置maxLine <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_he
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:layout_above="@id/bottom"
android:text="@string/sample_text"
android:textSize="18sp"/>
<View
android:id="@+id/bottom"
android:layout_width="match_parent"
android:layout_height="450dp"
android:layout_alignParentBottom="true"
android:background="@android:color/holo_orange_dark"/>
</RelativeLayout>
如何在不设置maxline的情况下省略此TextView,因为底部的“橙色”视图具有动态大小
更新:
我也尝试过这种方法,但也没有成功
编辑:
似乎无法解决此问题。将以下行添加到textview xml代码中 android:ellipsize=“end”
尝试添加
android:ellipsize=“end”
在textview中添加ellipsize并使用ConstraintLayout它不起作用,因为没有定义maxLine。我也尝试过constraintlayout,但也不起作用。你能尝试将{end | bottom}添加到textview吗?“bottom”不是要省略的参数
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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="@android:color/white">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_above="@id/bottom"
android:ellipsize="end"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/bottom"
android:text="@string/sample_text"
android:textSize="18sp"/>
<View
android:id="@+id/bottom"
android:layout_width="match_parent"
android:layout_height="450dp"
android:layout_alignParentBottom="true"
app:layout_constraintBottom_toBottomOf="parent"
android:background="@android:color/holo_orange_dark"/>
</android.support.constraint.ConstraintLayout>