Android TextView重力底部意外行为
我当前的Android项目要求在Android TextView重力底部意外行为,android,textview,Android,Textview,我当前的Android项目要求在TextView中显示多行文本(最多3行),并将文本放在文本视图的底部 我的文本视图定义如下:- <TextView android:id="@+id/my_title" android:layout_width="@dimen/image_width" android:layout_height="@dimen/image_height" android:layout_alignTop="@+id/other_title"
TextView
中显示多行文本(最多3行),并将文本放在文本视图的底部
我的文本视图定义如下:-
<TextView
android:id="@+id/my_title"
android:layout_width="@dimen/image_width"
android:layout_height="@dimen/image_height"
android:layout_alignTop="@+id/other_title"
android:layout_marginTop="@dimen/span_eight"
android:layout_toEndOf="@+id/dot"
android:maxLines="3"
android:gravity="bottom"
android:padding="2dp"
android:textColor="@android:color/white"
android:textSize="@dimen/text_twelve" />
我需要的是它显示为
"`Artificial cells, nanom`"
如何达到预期效果?尝试
android:gravity="bottom|start"
而不是
android:gravity="bottom"
使用:
将此属性添加到您的TextView
中,您将看到从开始到第三行末尾的文本,其中有3个点(…)表示文本超过3行 使用:
android:gravity="start"
重力中的“底部”值将更改显示行为。您可以根据边距改变文本视图的高度。您使用的是哪种布局?@DheerajRijhwani我使用的是相对论视图。android:gravity=“bottom | start”对显示的文本没有影响。“几乎”解决这个问题的方法是使用android:gravity=“bottom”&android:ellipsize=“end”,但我不想使用ellipsize,如果可以的话,您可以尝试使用外部库;
android:ellipsize="end"
android:gravity="start"