0

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!

1
  • I have edited my question, may be you get idea. Commented Mar 19, 2012 at 6:22

1 Answer 1

1

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).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.