我正在尝试制作一个自定义视图,它将具有动态数量的页面(1-3),每个页面包含动态数量的子视图(3-6)。这些页面实际上并没有定义,它们只是子视图的虚拟组。一页适合整个屏幕宽度。
我的问题是我不能在不使用child.setMinimumWidth(screenWidth / mChildrenPerPage)的情况下等间距放置孩子,但这会使他们太高。我怎样才能使它们保持在原来的高度,并将它们均匀地隔开。以下是我的代码
mIconWidth = screenWidth / mChildrenPerPage;
for (int i = 0; i < mPages; i++) {
for (int j = 0; j < mChildrenPerPage; j++) {
View icon = layoutInflater.inflate(R.layout.child, this, false);
((ImageView)icon).setImageDrawable(resources.getDrawable(R.drawable.some_icon));
icon.setMinimumWidth(mIconWidth);
addView(icon);
}
}发布于 2011-12-27 20:58:56
我必须手动设置xml布局和layout_weight。
https://stackoverflow.com/questions/7703104
复制相似问题