Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Super Contributor
Achin
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd
Accepted Solution

show text and image horizontal

hi. i have label which contains text the text for the label is static and i have image which is also static 
i want to show both horizontally ,, i'm using the below code. i have check in 9780 device it is working fine but it is looking fine in 9700 simulator i mean the text in label is showing half, but worked fine in 9780, i'll post my 9780 device screen shot and i'll post my code and please tell me the below code is ok or not ?

HorizontalFieldManager Psrofhfm = new HorizontalFieldManager();
			LabelField psrolabel = new LabelField("Sanjay Tandon and his wife Priya have together compiled and published five books, each containing 52 Inspirational short stories. They are Sunrays for Sunday, Sunrays for Monday, Sunrays for Tuesday, Sunrays for Wednesday, Sunrays for Thursday. All these books were blessed by Bhagwan Sri Sathya Sai Baba. Sunrays for Sunday is available in Hindi too. Sunrays for Sunday and Sunrays for Monday are available in Telugu as well.Sanjay Tandon has also written the biography of his father, “Balramji Dass Tandon- Ek Prerak Charitra”. This book was released by Sh. L. K. Advani, the then Leader of Opposition in a programme presided over by Sh. Parkash Singh Badal, Chief Minister, Punjab.Sanjay Tandon has for the last more than 10 years been sending a one-liner Inspirational thought to about 2500 people by email. Since about 3 years this service is being done daily through SMS too."){
				
				protected void layout(int width, int height) {
			        super.layout(240, height);
			        //this.setExtent(240, height);
			    }
			};
			
			Bitmap psrbit1=Bitmap.getBitmapResource("Literaryy.png");
			Bitmap psrscalingBitmap1=new Bitmap(230,400);//Then it sets the image according to your required width and height;
			psrbit1.scaleInto(psrscalingBitmap1, Bitmap.FILTER_LANCZOS); 
			BitmapField psrfieldDemo1 = new BitmapField(psrscalingBitmap1);  
			
			
			
			psrolabel.setMargin(10, 0, 0, 10);
			psrfieldDemo1.setMargin(20, 0, 0, 0);
			Psrofhfm.add(psrolabel);
			Psrofhfm.add(psrfieldDemo1);
			
			add(Psrofhfm);

 9700.png

Please use plain text.
Developer
peter_strange
Posts: 19,598
Registered: ‎07-14-2008
My Device: Not Specified

Re: show text and image horizontal

Sorry, I don't understand the question.  Can you please try to ask the question another way?

 

I would have thought that specifying the width as a hard coded number would not be advisable if you expect your code to be used on many different screen sizes.  So I would suggest you set the width of your LabelField and the image dependent on the width of the device being used, rather than hard coding values suitable for the 9700 screen size. 

Please use plain text.
Super Contributor
Achin
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd

Re: show text and image horizontal

ok, i got your point
Please use plain text.