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上的所有圖像看起來都一樣?
- 有沒有更好的方法來使我在這裏做的佈局?