1

How I can change some icons which are declared in strings.xml

<resources>
   ...
    <string name="icon_info">&#xf129;</string>
    <string name="icon_heart">&#xf004;</string>
   ....

and after I use them in some source files in java

Button txt=(Button) findViewById(R.id.infotxt); 
Button txt1=(Button) findViewById(R.id.hearttxt); 

Typeface webfont = Typeface.createFromAsset(getAssets(), "fontawesome-webfont.ttf");
txt.setText(" " + getString(R.string.icon_info) + " ...");
txt.setTypeface(webfont);
txt1.setText(" " + getString(R.string.icon_heart) + " ...");
txt1.setTypeface(webfont);

I would like to change these icons to other icons I have on my computer.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
stacJohn
  • 11
  • 1
  • 2

1 Answers1

1
  <string name="icon_info">&#xf129;</string>
  <string name="icon_heart">&#xf004;</string>

they are fonts, not real images icon!!!! you can do : 1. convert your icons to font and use it as same as above, look at this article also this is usefull. 2. put your image file in drawable or assets and use it as a normal image file

Majva
  • 88
  • 1
  • 5
  • Thank you for your answer. I think the first solution it's complicated – stacJohn May 27 '18 at 14:23
  • Is there any other ready fonts? maybe I can find similar icons – stacJohn May 27 '18 at 14:25
  • yes, google font icon... but I think it's better and easier to use materials icons. https://materialdesignicons.com/ and https://material.io/tools/icons/?style=baseline – Majva May 27 '18 at 14:39
  • How to use them? Can you help me by changing the code? partial – stacJohn May 27 '18 at 14:51
  • https://stackoverflow.com/questions/31689130/create-icon-button-android?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – Majva May 27 '18 at 16:53
  • choose your icon from https://materialdesignicons.com/ then select view vector drawable and save it as xml. put it in drawable folder and use it. an other way is using ImageButton instead of button – Majva May 27 '18 at 16:59