我需要根据Android屏幕绑定制作类似的内容,
S M T W T F S
我这样做:
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="45dp"
android:text="S M T W T F S" />
这不能正常工作,不是根据设备屏幕绑定。 我需要这样的东西:
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="45dp"
android:text="S""10dp""M""10dp""T""10dp""W""10dp""T""10dp""F""10dp""S""10dp" />
答案 0 :(得分:17)
我们可以使用它。
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="A B     C"/>
答案 1 :(得分:3)
使用Unicode字符NO-BREAK SPACE TextView
支持此
试试这个
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="45dp"
android:text="@string/days" />
将它放在String.xml
中<string name="days">S\u00A0M\u00A0T\u00A0W\u00A0T\u00A0F\u00A0S</string>
编辑1
它是满足您的要求但不是有效的方式,直到您找不到一个TextView
的解决方案,您可以尝试这样
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TextView
android:id="@+id/textView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="S" />
<TextView
android:id="@+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="M"
android:textAlignment="center" />
<TextView
android:id="@+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="T" />
<TextView
android:id="@+id/textView4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="W" />
<TextView
android:id="@+id/textView5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="T" />
<TextView
android:id="@+id/textView6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="F" />
<TextView
android:id="@+id/textView7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="S" />
答案 2 :(得分:2)
使用letterSpacing
属性来表示字母之间的间距:
android:id="@+id/txt_work"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:typeface="serif"
android:layout_below="@+id/txt_wecm"
android:layout_marginLeft="20dp"
android:textSize="32dp"
android:letterSpacing="0.1"
android:textColor="#fff"
android:text="World"
答案 3 :(得分:0)
TextView中的字母间距 -
<强>机器人:textScaleX 强>
设置文本的水平缩放系数。
必须是浮点值,例如“1.2”。
您可以根据字母之间所需的比例增加缩放系数。
android:textScaleX的Android文档。
答案 4 :(得分:0)
如果你想在textView中的Text之间留一些空格,你可以使用android:lineSpacingExtra =“10dp”
你可以这样试试: -<TextView
android:layout_width="match_parent"
android:layout_height="180dp"
android:lineSpacingExtra="10dp"
android:text="hi
hello"/>
答案 5 :(得分:-1)
textView.setText(Html.fromHtml("<span style=letter-spacing:10px>TEXT</span> "));
但是我不这样做
答案 6 :(得分:-1)
如果有人想要这样的文字:“科学 和 技术” 然后, android:text=" 科学\n 和\n 技术" 为我工作。