0

I am creating a number of imageviews and textviews on runtime depending on the objects in my webservice. I'm creating linearLayout horizontal and adding imageviews and textviews to layout, now the issue is the text are against images, and images are of different width so i want to set x position of my textviews so they all look align how can this be done,

i tried absolutelayout(warning deprecated) , setx(no method showed)

MBMJ
  • 5,323
  • 8
  • 32
  • 51
Raheel Sadiq
  • 9,847
  • 6
  • 42
  • 54

3 Answers3

0

I presume you mean this is a vertical LinearLayout, and each text/image combo is added below the previous one? In that case, you could have two LinearLayouts next to each other like two columns, adding the images to one and the text fields to the other. Then the widest image would stretch its layout to that width and all text fields would be just to the right of it.

Cathal Comerford
  • 1,020
  • 1
  • 9
  • 12
  • i did it by setting the image width extra(max that one could be) in its layout param and set the margin left of the text, as im adding both in a horizontal layout so the problem fixed – Raheel Sadiq Jun 13 '12 at 10:41
0

you can use resized image on runtime based on the pannel height and width for resizing image on runtime view this stack overflow thread resizing image java getScaledInstance

Community
  • 1
  • 1
Mohit
  • 93
  • 7
  • i did it by setting the image width extra(max that one could be) in its layout param and set the margin left of the text, as im adding both in a horizontal layout so the problem fixed – Raheel Sadiq Jun 13 '12 at 10:41
0

Use weight property in your ImageView and TextView

Dmitry Zaytsev
  • 23,650
  • 14
  • 92
  • 146