0

When I drag a gridview into the graphical layout screen in Android Eclipse, and give it wrap content, then it fills the height of the screen with 24 placeholders.

How can I limit its length? Note this is fine when I actually run the application because my adapter adds 6 items and it isn't very long. I simple want a way of telling eclipse that in an absence of real data that it should draw something with say 6 placeholder items

user2022581
  • 923
  • 2
  • 9
  • 16

1 Answers1

1

I don't think it's possible to set the number of items just for the aesthetic purposes of the graphical view in xml builder. If you must do it, you could set the height to look acceptable in the XML via a literal value such as 100dp, then set the layout params for height to Wrap Content when you assign and initialize it in your onCreate(). That way, it will look the height you require in the graphical interface editor, but will wrap the number of elements you add to it when it's running on the device.

http://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html

I agree this is not the most elegant solution, but it would probably work.

pfairbairn
  • 451
  • 2
  • 8