我有5个方形ImageButton,我想在屏幕底部并排排列。我有各一套(不同的ID)为:如何保持图像按钮宽高比在android系统?
<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);
}
我想怎么把它做的是扩展宽度适合整齐地在屏幕的底部(其它现在OK)并排的一面,但具有高度自动缩放,以匹配的宽度为好。这可能吗?我不想因为那时它把周围的ImageButton边框使用setImageSource。
这并没有为我工作读吗......? – clayton33 2011-01-11 13:00:19
@ clayton33:看看EDIT1 – barmaley 2011-01-11 14:07:24
聪明的回答(并且不会弄乱子类),谢谢! – Rick77 2013-05-02 09:52:23