我怎么能显示一个按钮多行文本 [英] how can I display multiple lines of text on a button

查看:211
本文介绍了我怎么能显示一个按钮多行文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的按钮的layout_width设置为match_parent。

My button's layout_width set to match_parent.

为了在按钮上显示多行,我想:

In order to display multi lines on the button, I tried:

  • 插入'\ N'插入按钮上的文本

  • insert '\n' into the text on button

设置单行假套MAXLINES为2或3

set Singleline false set Maxlines to 2 or 3

转换HTML代码Html.fromHtml

convert html from Html.fromHtml

毫无效果。 '\ N'露面的按钮一个小广场上同时显示单行文本。

Nothing worked. '\n' showed up as a small square on the button while showing single line of text.

没有任何人有任何想法,为什么发生这种情况,我怎么能解决这个问题?

Does anybody have any idea why this is happening and how I can fix this?

更新:我刚刚发现我是用自定义按钮,有它自己的文字图形。这就是原因。对困惑感到抱歉。我只是惩罚自己被敲我的头。

UPDATE: I just found out I was using custom button that has its own text drawing. That's the reason. Sorry for the confusion. I just punished myself by banging my head.

推荐答案

如果你想添加一个新的行布局XML文件:

If you're trying to add a new line in a layout XML file:

使用&放大器;#10; (新行)

    android:text="Hi
Hello"

如果你想加入code一个新的生产线,只是用'\ N'一样,同样在其他任何文本。

If you're trying to add a new line in code, just use '\n', same as in any other text.

如果你不能看到第二行,也可能是您的按钮没有足够的高度。 IE浏览器,在我的情况下,包含该按钮的布局有一个固定的高度正好让我的按钮完全显示一行文字。

If you can't see the second line, it may be that your Button doesn't have enough height. IE, in my case, the layout containing the button had a fixed height that just happened to make my button perfectly display one line of text.

这篇关于我怎么能显示一个按钮多行文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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