How can I reduce font size?

How to reduce Font size?

  • public class TestEye extends MainScreen { LabelField l1,l2; RichTextField rch; VerticalFieldManager vfm; Font myfont1; String word[]={"F D","N P","U H","F Z","K R","U V","Z E","E K","P Z","V N"}; public TestEye() { vfm=new VerticalFieldManager(VerticalFieldManager.USE_ALL_WIDTH|VerticalFieldManager.USE_ALL_HEIGHT) { protected void paint(Graphics graphics) { graphics.setColor(Color.BLACK); graphics.fillRect(0, 0, Display.getHorizontalResolution(), Display.getVerticalResolution()); super.paint(graphics); } }; l1=new LabelField("----------------",Field.USE_ALL_WIDTH|Field.USE_ALL_HEIGHT); l2=new LabelField("----------------",Field.USE_ALL_WIDTH|Field.USE_ALL_HEIGHT); rch=new RichTextField() { public void paint(Graphics g) { g.setBackgroundColor(Color.BLACK); g.setColor(Color.WHITE); super.paint(g); } }; vfm.add(l1); vfm.add(l2); vfm.add(rch); add(vfm); System.out.println("::::::::::::::::end test eye:::::::::::::::"); push(word); } public void push( final String arr1[]) { new Thread(new Runnable() { public void run() { int k=20; for( int i=0;i<10;i++) { try { String data=arr1[i]; Font myfont1=Font.getDefault().derive(Font.PLAIN,k); rch.setFont(myfont1); rch.setText(" "+(data)); k=k-2; } catch(Exception ex) { ex.printStackTrace(); } try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } } } }).start(); } } i have to reduce Font size for each word used in String array. this is my code but here inside for loop Font is not working so please check it and give me some suggestion thanks

  • Answer:

    you can try ActiveRichTextField. in ActiveRichTextField not only you can give different fonts, you can give different colors also. e.g. String data = "Hello World!"; int offsets[] ={0,5,data.length()}; Font[] fonts = new Font[] { Font.getDefault(), Font.getDefault()}; int bg[] = new int[] { Color.WHITE, Color.WHITE}; int fg[] = new int[] { Color.BLACK, Color.RED}; byte attributes[] = {0,1}; add(new ActiveRichTextField(data, offsets, attributes, fonts, fg, bg, 0));

sudhan sudh at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

You are setting the font for the entire field in your loop. If you want different portions of the field contents to be in different fonts, that's not the way to do it. Take a look at the docs for http://www.blackberry.com/developers/docs/6.0.0api/net/rim/device/api/ui/component/RichTextField.html for how to use the multi-argument setText methods to define different fonts for different parts of the text.

Ted Hopp

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.