如何换行的Andr​​oid TextView的看法? [英] How to line wrap Android TextView views?

查看:100
本文介绍了如何换行的Andr​​oid TextView的看法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让一个TextView来包装它的多行文字,但它总是似乎只是在第一行的末尾得到剁掉。下面是从我的观点相关的XML:

I'm trying to get a TextView to wrap it's text over multiple lines, but it always just seems to get chopped off at the end of the first line. Here's the relevant XML from my view:

    <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>

我已经试过各种事情,使之包,我elipsize设置为none,scrollHorizo​​ntally假的,我甚至试图去precated SINGLELINE =假的,那是行不通的。

I've tried various things to make it wrap, I've set elipsize to none, scrollHorizontally to false, I've even tried the deprecated singleLine = false, and that doesn't work.

有似乎是缺乏的例子展示了如何做到这一点,很多人对SO问同样的问题,没有一个是有一个明确的答案。

There seems to be a lack of examples showing how to do this, and numerous people on SO asking the same question, none of which have a definitive answer.

推荐答案

因此​​,答案是RelativeLayout的&放大器;多行的TextView不玩好起来,改变2内RelativeLayout的元素的LinearLayout和TextView的公司突然间有了多行。

So the answer is that RelativeLayout & multiline TextView don't play nice together, change the 2 inner RelativeLayout elements to LinearLayout and the TextView's suddenly have multiple lines.

这篇关于如何换行的Andr​​oid TextView的看法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆