2011-10-09 70 views
0

我试着做,将有页面(1-3),每个包含的子视图动态数字​​(3-6),动态数字自定义视图。实际上并没有定义的页面,他们的孩子刚刚意见虚拟团体。一页适合屏幕宽度。Android的自定义视图间距

我的问题是,我不能空儿不使用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); 
     } 
    } 

回答

0

我必须设置一个xml布局并手动设置layout_weight。