我有一个场景,我需要为android:text属性值设置空格。
android:text =“输入类型”--->我需要在“输入”和“类型”字符串之间输出5个空格
我怎样才能达到上述效果。
先谢谢
答案 0 :(得分:1)
<TextView
android:id="@+id/xxx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/empty_spaces" />
在字符串中。
<string name="empty_spaces">Input\t\t type</string>
答案 1 :(得分:1)
使用字符串资源更好。
将所有字符串值放在res/values/strings.xml
上的文件中。
如果你想增加空间,你可以用双引号括起你的文字。
您可以在文档中看到一个示例: http://developer.android.com/guide/topics/resources/string-resource.html#FormattingAndStyling
答案 2 :(得分:0)
您可以按\u0020
<TextView android:text="Input\u0020\u0020\u0020\u0020\u0020types" />
答案 3 :(得分:0)
将此<string name="stringsample">Sample: </string>
与您的字符串一起添加到xml文件中
template