Java的机器人:使用附加TextView的一个换行符 [英] Java android: appending a newline using TextView

查看:118
本文介绍了Java的机器人:使用附加TextView的一个换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想以某种方式增加新的生产线,以我的线性布局:

I just want to add a new line somehow to my linear layout:

layout = (LinearLayout) findViewById (R.id.layout);  

... //some other code where I've appended some strings already

final TextView nline = new TextView(this);
nline.setText(Html.fromHtml("<br>")); //i also tried:  nline.setText("\n");
layout.addView(nline);

但是,这只是增加了一些空间。有人可以帮我吗?谢谢你。

But this just adds a few spaces. Can someone help me out? Thanks.

推荐答案

如果你只是想有两个观点之间的一些空的空间,你可以这样做在你的XML(假设你使用XML的布局)。这样的事情可以工作,基本上投入视图具有透明背景,并给予高度。这是假设你有任何参数,你想在你TextViews。

If you just want to have some empty space between two other views, you could do this in your XML (assuming you're using XML for the layout). Something like this could work, basically putting in a View with a transparent background and given height. This is assuming you have whatever parameters you want in your TextViews.

<TextView />

<View android:background="#00000000"
      android:layout_height="12dp" //or whatever density pixel height you want
      android:layout_width="fill_parent" />

<TextView />

另外,你尝试过什么之上?你可以尝试一个空格和换行...可能的工作。

Also, in what you tried above... you could try a space and newline... that might work.

nline.setText(" \n");

这篇关于Java的机器人:使用附加TextView的一个换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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