我使用android文本视图在manifest.XML文件中显示常量数据,我需要显示80%这样的文本但现在显示80。
这是我的文本视图小部件,您可以帮助我。
<TextView
android:text="80" />
答案 0 :(得分:2)
如果要在xml文件中显示百分比,则必须使用strings.xml文件,如下所示:
<string name="percent_sign">80%</string>
在布局文件中使用此字符串显示百分比:
android:text="@string/percent_sign" />
or
android:text="80%" />
而不是
android:text="80" />
答案 1 :(得分:0)
如果要在TextView
中显示百分比符号,只需在XML布局中添加“%”符号:
android:text="80%"
或在你的java中:
TextView.setText("80%");
答案 2 :(得分:0)
<TextView android:text="80%"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>