У меня есть 5 квадратных кнопок изображения, которые я хочу выстроить рядом друг с другом в нижней части экрана. У меня есть каждый набор (разные идентификаторы) как:
<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, потому что тогда он помещает рамку вокруг кнопки изображения.