use setTextSize with proper density calculations.
http://developer.android.com/reference/android/widget/TextView.html#setTextSize%28int,%20float%29 On Fri, Aug 17, 2012 at 6:22 AM, Goncalo Oliveira <gonc...@minkan.net>wrote: > Hello, > > I was trying to use different screen size styles to apply on text fields > without the need to edit every single layout in every single variant. > So, I added three styles in three different files under values, > values-large and values-xlarge. > > <style name="NormalText" parent="@android:style/TextAppearance"> > <item name="android:textSize">18sp</item> > <item name="android:textColor">#B9BD4D</item> > </style> > > <style name="LargeText" parent="@android:style/TextAppearance"> > <item name="android:textSize">20sp</item> > </style> > > <style name="TitleText" parent="@android:style/TextAppearance"> > <item name="android:textSize">22sp</item> > <item name="android:textStyle">bold</item> > </style> > > The size is obviously different in every file. > > Initial comment, it worked out ok. I set the textAppearance field in the > layouts and I do get the intended result. > The thing is... not everything is static, meaning, in some layouts I have > to create a few dynamic controls with code. And obviously, I tried applying > the same style but with code. So here I go on writing... > > myTextView.SetTextAppearance( ctx, Resource.Style.NormalText ); > > Well... it works actually. The text is even yellow (I added this to > confirm it was using the right file). > The problem is... the text size doesn't look like the same between > designer generated and code generated texts. > > So... I do a test to confirm. New activity, two text fields. > On both I set on the axml file the textAppearance, but on one of them, in > code, I call SetTextAppearance with the same resource id. > Confirmed... the size IS NOT the same... they're both yellow, so it's > going for the right file and for the right resource id but... it's not the > same size! > > Is this a bug? Am I missing something? > > Cheers > > -- > Gonçalo Oliveira > > _______________________________________________ > Monodroid mailing list > Monodroid@lists.ximian.com > > UNSUBSCRIBE INFORMATION: > http://lists.ximian.com/mailman/listinfo/monodroid > > -- Extreme Knowledge is not something for which he programs a computer but for which his computer is programming him. -Wozniak - if my programming advice has helped you, feel free to donate to : <https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KYUXV2PG88YQQ> <https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KYUXV2PG88YQQ> <https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KYUXV2PG88YQQ>
_______________________________________________ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid