画面の下部に並べて配置したい5つの正方形のImageButtonsがあります。私はそれぞれ(異なる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 を使用したくないのは、イメージボタンの周りに境界線を配置するためです。