2
在我的代码我需要创建一个表,每列包含位图和文本 - 我创建此表动态。 所以,我通过使用此代码这样做:如何控制将在ImageButton上绘制的位图大小?
for (int i = 0; i < collection.size(); i++)
{
ObjectITem item = collection.get(i);
LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
TextView textView = new TextView(this);
textView.setText(item.getText());
linearLayout.addView(textView);
linearLayout.addView((new ImageButton(this)).setImageBitmap(item.getBitmap());
layout.addView(linearLayout, LayoutParams.WRAP_CONTENT);
}
这个代码工作不错 - 但因为渊源图像不相同大小 - 我看到上出现的ImageButton的图像看起来并不好。
- 如何让ImageButton上的所有图像看起来都一样?
- 有没有更好的方法来使我在这里做的布局?