3

I'm trying to get formatted text and special characters from the strings.xml. I don't have any problem either getting formatted text (bold, superscript, subscript, etc) or getting some greek characters (beta, eta), even chinese characters. But what I'm not able to retrieve is the greek character "capital phi" (HTML-code: ϕ). Does anyone know how to do it?

Here's the code I'm using.

strings.xml

<resources>
    <string name="beta">&#946;</string>
    <string name="eta">&#951;</string>
    <string name="phi">&#981;</string>
    <string name="zhongwen">为什么呀!</string>
    <string name="area"><b>A</b><sub><small>s,t</small></sub> [cm<sup><small>2</small></sup>]</string>
</resources>

MainActivity.java

public class MainActivity extends ActionBarActivity {

    TextView textView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        textView = (TextView)findViewById(R.id.text_view);

        textView.setTextSize(50);
        textView.setGravity(Gravity.CENTER);
        textView.setText(getText(R.string.beta));
        textView.append(getText(R.string.eta));
        textView.append(getText(R.string.phi));
        textView.append(getText(R.string.zhongwen));
        textView.append(getText(R.string.area));
    }
}
daalgi
  • 169
  • 1
  • 14

1 Answers1

1

This is because android's font doesn't have these characters in it , All you have to do is download a compatible font , check it on your computer (Ms word , wordpad ) . Then put the font file into your android asset folder and go through a few tutorials or use libraries like fontify.

TheAnimatrix
  • 566
  • 1
  • 6
  • 19