【发布时间】:2011-06-07 02:50:36
【问题描述】:
我有 5 个方形 ImageButton,我想在屏幕底部并排排列。我将每一组(不同的 id)设置为:
<ImageButton
android:id="@+id/box1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:layout_weight="1"
android:layout_margin="1dp"
/>
我在主 java 中分配了这样的背景:
int[] imageIds = new int[] {R.id.box1,R.id.box2,R.id.box3,R.id.box4,R.id.box5};
for(int i = 0; i<5; i++){
imageButtons[i] = (ImageButton) findViewById(imageIds[i]);
imageButtons[i].setBackgroundResource(R.drawable.blank);
}
我想让它做的是缩放宽度以整齐地并排放置在屏幕底部(现在可以了),但高度也会自动缩放以匹配宽度。这可能吗?我不想使用 setImageSource,因为它会在图像按钮周围设置边框。
【问题讨论】:
标签: android imagebutton aspect-ratio