I am developing an android app and I want to write the Bitcoin symbol in a TextView.
Is there any code for that like "\u20B9" for Rupees?
Asked
Active
Viewed 1,178 times
0
Community
- 1
- 1
nilesh prajapati
- 108
- 8
-
have you tried \u20BF as this is the suggested bitcoin symbol. – Tenten Ponce Jan 03 '18 at 10:01
-
try this [answer](https://stackoverflow.com/a/23608552/8867002) for unicodes – Jyoti JK Jan 03 '18 at 10:10
-
yes . i tried but its not working @TentenPonce – nilesh prajapati Jan 03 '18 at 10:11
-
@nileshprajapati Please check the answer given below and let me know if it is working for you. – Rahul Sharma Jan 03 '18 at 10:29
-
can anyone tell me whats wrong in this question why vote down (-1) ? – nilesh prajapati Jan 03 '18 at 10:52
2 Answers
2
Android supports Bitcoin Unicode symbol since Android O, you can read more about it from this link. Just try to run your code in Android O and I'm sure that everything will be fine.
But if still want to use TextView, to show BTC symbol, consider FontAwesome, it's actually designed for WEB, but it also possible to use in Android.
- Download icons pack.
- Put
ttffont file to yourassetsfolder Then get
Typefaceobject and set it to yourTextView:String fontName = "fa-brands-400.ttf"; Typeface fontAwesome = Typeface.createFromAsset(getAssets(), "fonts/" + fontName); textView.setTypeface(fontAwesome);Add string
XMLresource withFontAwesomecode point ofBTCsymbol:<string name="btc_fa"></string>Set this string to
TextView:textView.setText(R.string.btc_fa);
As the result, you will get this:
Denysole
- 3,903
- 1
- 20
- 28
1
Create a string in strings.xml like the following one:
<string name="bitCoin">\u20BF</string>
Use the following to create the textView with BitCoin Symbol:
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="@string/bitCoin"/>
You will have your bitcoin symbol in textView like below
Rahul Sharma
- 2,867
- 2
- 27
- 40
-
-
@matrix have u tried to implement it? Please take some time and implement as described above and you will get the bitcoin symbol on android. – Rahul Sharma Jan 03 '18 at 10:27
-
I didnt say it does not work. I just said that you shouldn't create strings just to translate some unicode – matrix Jan 03 '18 at 10:29
-
@matrix Ya true indeed. We shouldn't but It will can cater the needs till we find the optimum solution for the problem. – Rahul Sharma Jan 03 '18 at 10:33
-
just tried this, it works. But I'm not sure if it'll show OK on all target devices. – pseudozach Apr 29 '18 at 22:00


