Android 实现 EditText 文本自动换行

Android 实现 EditText 文本自动换行,第1张

很简单,在布局 XML 文件的 EditText 中加上下面这行:

android:inputType="textMultiLine"

即可。

Matlab的title如何实现换行显示?

比如下面的程序,怎么才能在'B Range‘前面开始换行呢?

a=1b=2c=3d=4

title(['abc','L Range:',num2str(a),'(nm)','~~',num2str(b),'(cm)','B Range:',num2str(c),'(cm)','~~',num2str(d),'(cm)'])

使用元胞数组便可以了。

a=1b=2c=3d=4

title({['abc','L Range:',num2str(a),'(nm)','~~',num2str(b),'(cm)']['B Range:',num2str(c),'(cm)','~~',num2str(d),'(cm)']})

下面的程序是绘制岩石圈在地表和地下垂向载荷作用下进行挠曲的示意图。程序中便包含利用元胞数组使title中的字符换行的程序。

如title({'(b)''equilibrium state'})

% % % %-------------------------------

x=-2*pi:0.01:2*pi

y=sin(x+pi/6)

y1=0*x-3

y2=0*x-6

subplot(3,3,1)

plot(x,y,'k',x,y1,'k',x,y2,'k','linewidth',2)

ylim([-6.5 1])

text(x(end)+1,y(end),'surface')

text(x(end)+1,y1(end),'Moho')

text(x(end)+1,y2(end),'LAB')

text(x(1)-2,y(1),'H_I')

title({['(a)']['initial surface loading']})

axis off

y=sin(x+pi/6)*3/5

y1=-3-sin(x+pi/6)*2/5

y2=-6-sin(x+pi/6)*2/5

subplot(3,3,2)

plot(x,y,'k',x,y1,'k',x,y2,'k','linewidth',2)

hold on

y1=0*x-3

y2=0*x-6

plot(x,y1,'k--',x,y2,'k--','linewidth',2)

text(x(end)+1,y(end),'surface')

text(x(end)+1,y1(end),'Moho')

text(x(end)+1,y2(end),'LAB')

text(x(1)-3,y(1),'H_T')

text(x(1)-3,y1(1),'W_T')

text(x(1)-3,y2(1),'W_T')

title({'(b)''equilibrium state'})

ylim([-6.5 1])

axis off

y=0*x

y1=-3+sin(x-pi/4)

y2=0*x-6

subplot(3,3,7)

plot(x,y,'k',x,y1,'k',x,y2,'k','linewidth',2)

ylim([-6.5 1])

text(x(end)+1,y(end),'surface')

text(x(end)+1,y1(end),'Moho')

text(x(end)+1,y2(end),'LAB')

text(x(1)-3,y1(1),'W_I')

title({'(c)''initial Moho loading'})

axis off

y=-sin(x-pi/4)*1/5

y1=-3+sin(x-pi/4)*4/5

y2=-6-sin(x-pi/4)*1/5

subplot(3,3,8)

plot(x,y,'k',x,y1,'k',x,y2,'k','linewidth',2)

hold on

y=0*x

y2=0*x-6

plot(x,y,'k--',x,y2,'k--','linewidth',2)

text(x(end)+1,y(end),'surface')

text(x(end)+1,y1(end),'Moho')

text(x(end)+1,y2(end),'LAB')

text(x(1)-3,y(1),'H_B')

text(x(1)-3,y1(1),'W_B')

text(x(1)-3,y2(1),'H_B')

title({'(d)''equilibrium state'})

ylim([-6.5 1])

axis off

y=sin(x+pi/6)*3/5-sin(x-pi/4)*1/5

y1=-3-sin(x+pi/6)*2/5+sin(x-pi/4)*4/5

y2=-6-sin(x-pi/4)*1/5-sin(x+pi/6)*2/5

subplot(3,3,6)

plot(x,y,'k',x,y1,'k',x,y2,'k','linewidth',2)

hold on

y2=0*x-6

plot(x,y2,'k--','linewidth',2)

ylim([-6.5 1])

text(x(end)+1,y(end),'surface')

text(x(end)+1,y1(end),'Moho')

text(x(end)+1,y2(end),'LAB')

text(x(1)-3,y(1),'H')

text(x(1)-3,y1(1),'W')

text(x(1)-6,y2(1),'W_T+H_B')

title({'(e)''integrated equilibrium state'})

axis off

% % % %-------------------------------

读取edittext的内容用gettext().tostring().trim()就可以,trim()是去掉前后空格的,可以差资料看看

截取字符串的话,看这个字符串是固定的位数吗?还是什么?

可以用indexof获取某个字符第一此出现的索引,然后用substring()截取字符串


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11634228.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-17
下一篇 2023-05-17

发表评论

登录后才能评论

评论列表(0条)

保存