its not good that you hadn't assigned layoutParams to the view anyway... you should do that before you do any other changes, it might fix the issue. But if that won't work, I've had similar issues before, it seems like that on some specific layouts android just doesn't do alignments properly. your easier trick to avoid it (besides creating your own class that will center the text on its own) is to instead of centering the text, is to center the view. change it to wrap_content and put it in a relativelayout/framelayout and center it in them.
On Saturday, December 22, 2012 9:47:46 AM UTC+2, Sandy wrote: > > Hello Everyone... > > I need your help urgently.. > > I am working on application where I require to use Sanskrit fonts & align > them in center. I am able to display sanskrit font using following code. I > do specify the property for center gravity, still it is not working any > more. Text is not getting proper center of the screen. Here is my code that > I am using. > > *TextView tv = new TextView(this); > * > *tv.setGravity(Gravity.CENTER_HORIZONTAL**| Gravity.CENTER_VERTICAL);* > *Typeface font = Typeface.createFromAsset(getAssets(), "mangal.ttf"); > * > *tv.setTypeface(font); > * > *tv.setText(R.string.string1);* > * > * > > Please help me to solve this issue. > > Waiting for your replies. > Thank You > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en