Stu*_*haw 4 android textview android-layout
我试图让TextView将它的文本包装在多行上,但它似乎总是在第一行的末尾被切断.这是我视图中的相关XML:
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="@+id/relExtraInfo"
android:layout_below="@+id/titleContainerLayout">
<RelativeLayout android:layout_height="wrap_content"
android:layout_width="fill_parent" android:layout_below="@+id/titleArtwork"
android:id="@+id/relStarring">
<TextView android:textStyle="bold" android:layout_height="wrap_content"
android:text="Starring:" android:layout_width="wrap_content"
android:id="@+id/lblStarring" android:layout_alignParentLeft="true"></TextView>
<TextView android:layout_alignTop="@+id/lblStarring"
android:text="This is a very long peice of text to try and get the TextView to spill over multiple lines."
android:layout_alignBottom="@+id/lblStarring" android:id="@+id/txtStarring"
android:layout_toRightOf="@+id/lblStarring" android:layout_width="fill_parent"></TextView>
</RelativeLayout>
<RelativeLayout android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="@+id/relDirector"
android:layout_below="@+id/relStarring">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:layout_alignParentLeft="true"
android:text="Director:" android:textStyle="bold" android:id="@+id/lblDirector"></TextView>
<TextView android:layout_height="wrap_content"
android:text="TextView" android:layout_width="wrap_content"
android:layout_alignTop="@+id/txtDirector"
android:layout_alignBottom="@+id/txtDirector" android:id="@+id/txtDirector"
android:layout_toRightOf="@+id/lblDirector" android:ellipsize="none"></TextView>
</RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我已经尝试了各种各样的东西来使它换行,我将elipsize设置为none,scrollHorizontally设置为false,我甚至尝试了弃用的singleLine = false,但这不起作用.
似乎缺乏显示如何做到这一点的例子,并且很多人在SO上提出同样的问题,其中没有一个有明确的答案.
所以答案是RelativeLayout和多行TextView不能很好地结合在一起,将2个内部RelativeLayout元素更改为LinearLayout,而TextView突然有多行.
| 归档时间: |
|
| 查看次数: |
7459 次 |
| 最近记录: |