在Android中的按钮上编写多行文字 [英] Write Multiline Text on Button in Android
本文介绍了在Android中的按钮上编写多行文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道,如何在按钮上写多行文字
I want to know, How to write Multiline Text on Button
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="100dp"
android:background="@drawable/layout_border"
android:text="Hours Mon - sat 5pm" />
我越来越像这样:-
但是需要这种按钮:-
已:-
现在,通过使用@Sino K D给出的答案,我得到了类似的东西:
Now i got something like this, by using answer given by, @Sino K D :
但仍在寻求帮助,
在左侧添加可绘制对象后,得到以下内容:-
After adding drawable to left side, getting this:-
推荐答案
使用
(新行)
示例:-
android:text="Hi Hello"
OR
1)在../res/values/strings.xml中定义:
1) Define in ../res/values/strings.xml:
<string name="multilines">Line1Line1\nLine2Line2</string>
2)在布局文件中引用它:
2) Refer it in the layout file:
<Button
android:id="@+id/btn_multilines"
android:text="@string/multilines"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
</Button>
这篇关于在Android中的按钮上编写多行文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文