我有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