user3619128
user3619128

Reputation: 285

how can we display percentage symbol in textview in android

I am using android text view to display the constant data in manifest.XML file, I need to display the text like this 80% But now it displays 80.

Here is my text view widget can you please help to me.`

   <TextView
         android:text="80" />

Upvotes: 2

Views: 4191

Answers (3)

NavinRaj Pandey
NavinRaj Pandey

Reputation: 1704

 <TextView android:text="80&#x0025;"
     android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

Upvotes: 0

Sagar Maiyad
Sagar Maiyad

Reputation: 12733

if you want to display percentage in xml file then you have to use strings.xml file for that like below:

<string name="percent_sign">80&#x0025;</string>

use this string in your layout file for display percentage:

android:text="@string/percent_sign" />

or

android:text="80&#x0025;" />

instead of

android:text="80" />

Upvotes: 2

Menma
Menma

Reputation: 809

If you want to display percentage symbol in TextView you just need add "%" symbol in your XML layout:

 android:text="80%"

or in your java :

TextView.setText("80%");

Upvotes: 0

Related Questions