0
私は、それぞれが動的な数の子ビュー(3-6)を含む動的なページ数(1-3)を持つカスタムビューを作成しようとしています。ページは実際には定義されておらず、子ビューの仮想グループに過ぎません。 1ページが画面の幅に収まります。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);
}
}