Reputation: 1070
I am adding multiple image views in Linear Layout. These views are adding and also linear layout size is increasing but these views are not shown.
Here is my code:
FrameLayout rootLayout = (FrameLayout) rowView.findViewById(R.id.frame_layout);
LinearLayout parentLayout = (LinearLayout) rootLayout.findViewById(R.id.linear_layout);
for (int i = 0; i < itemList.size(); i++)
{
Item item = itemList.get(i);
int xCoord = (int) Utils.getPosition(resizedValues.originalWidth, resizedWidth, hotSpot.getPositionX(), context);
int yCoord = (int) Utils.getPosition(resizedValues.originalHeight, resizedHeight, hotSpot.getPositionY(), context);
Utils.print("xCoord = " + xCoord + " : yCoord = " + yCoord);
ImageView imageView = new ImageView(getApplicationContext());
imageView.setImageResource(R.drawable.hotspot);
imageView.setAdjustViewBounds(true);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.leftMargin = xCoord;
params.topMargin = yCoord;
params.gravity = Gravity.TOP | Gravity.LEFT
imageView.setLayoutParams(params);
Utils.print("params.leftMargin = " + params.leftMargin + " : params.topMargin = " + params.topMargin);
Utils.print("child count = " + parentLayout.getChildCount());
parentLayout.addView(imageView, i);
}
Thanks in advance!
Upvotes: 0
Views: 2188
Reputation: 2213
You need a Scrollview as a parent of your parentLayout, just take out the frameLayout and add a scrollviewHorizonatal instead. I hope this help you.(not too late).
Upvotes: 1