安卓敬酒不适合文本 [英] android toast doesn't fit text

查看:159
本文介绍了安卓敬酒不适合文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个应用程序,我不得不使用大量的祝酒词。

I am developing an application where I have to use numerous toasts.

我通过展示这些祝酒词:

I display these toasts by using:

Toast.makeText(context, "Some medium-sized text", Toast.LENGTH_SHORT).show();

该显示器敬酒,但是,有一条线的高度,而文本显示在多行。其结果是,我无法查看敬酒的所有文本。

The displayer toast, however, has the height of one line, while the text is displayed on multiple lines. The result is that I can't view all the text in the toast.

我该如何解决这个问题?

How can I fix this?

推荐答案

尝试插入一个回车和换行要拆分的文本。

Try inserting a carriage-return and line-feed where you want to split the text.

这些字符重提旧打字机车型。回车是气缸移动回到开始和换行是气缸轧制(馈送)由一行。

These characters refer back to the old typewriter models. Carriage return was the cylinder moving back to the start and line feed was the cylinder rolling (feeding) by one line.

在计算两个转义字符(特殊codeS,允许非打印codeS字符串由$ P $内用反斜杠pfixing其中 \ psented这些被重新$ P $ )。

In computing these are represented by two escaped characters (special codes that allow non-printable codes inside a string by prefixing them with a backslash \).

  • 回车重新由 \ r psented $ P $
  • 换行是重新通过 psented \ñ$ P $ (你能记住这是一个新行)。
  • A carriage return is represented by \r
  • A line-feed is represented by \n (you can remember this as a new line).

一些非Unix系统(如Windows)要求同时,其他人(如Linux的在其上的Andr​​oid为基础),只需要在新的生产线,但它通常是安全的无处不在两者都做。有一件事是重要的是他们是在顺序。它必须是 \ r \ñ

Some non-unix systems (e.g. Windows) require both, others (e.g Linux on which Android is based) only need the new line but it is generally safe to do both everywhere. The one thing that is essential is the order they are in. It must be \r\n

要把它放到你的例子:

Toast.makeText(context, "First line of text\r\nSecond line of text",1).show();

在Android的,你应该能够减少这种只换行字符作为基于Unix的系统并没有那么挑剔:

In Android you should be able to reduce this to just the new line character \n as unix based systems are not so fussy:

Toast.makeText(context, "First line of text\nSecond line of text",1).show();

这篇关于安卓敬酒不适合文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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