我在线性布局中添加多个图像视图。这些视图正在添加,线性布局大小也在增加,但这些视图未显示。
这是我的代码:
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);
}
提前致谢!
答案 0 :(得分:1)
您需要Scrollview作为parentLayout的父级,只需取出frameLayout并添加scrollviewHorizonatal。我希望这对你有帮助。(不要太晚)。