Застрял на этом в течение нескольких дней, все просто не работает с тем, как я настраиваю это. У меня есть большая сетка ImageViews, которые имеют одинаковый размер. Он состоит из горизонтального LinearLayout и внутри него, 5 вертикальных LinearLayouts (первое изображение).Android Linear/RelativeLayout размер с ImageViews
Что я хочу (и мне все равно, как это использовать RelativeLayout, Linear или Tables), если бы я должен был сказать, что изображение # 2 на большее изображение (в частности, 3x3 из меньших) эффективно «перезаписать» эти изображения (как показано на рисунке 2).
Я попытался сделать это, установив «перезаписанные» изображения (3,4,7,8,9,12,13,14) на setVisibility (GONE), который отлично работает, но затем второй вертикальный LinearLayout расширился чтобы соответствовать размеру нового изображения, которое я не хочу. Если я попытаюсь установить его на fill_parent, хотя он сквозит размер изображения. В результате я получаю третью картину.
Все связанный XML-код (коды идентификаторов совпадают на изображении):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView android:id="@+id/gs01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs06"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView android:id="@+id/gs02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs07"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView android:id="@+id/gs03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs08"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView android:id="@+id/gs04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs09"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView android:id="@+id/gs05"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
</LinearLayout>
</LinearLayout>
Если бы я сделать это с помощью RelativeLayouts, я бегу в проблемы, когда я setVisibility (Gone) с позиции может очень хорошо ссылаться на отсутствующий вид. Установка его в INVISIBLE просто оставляет пустое пространство, когда то, что я действительно хочу, должно быть размером 0px размером 0px.
Любая помощь вообще будет оценена по достоинству; Кажется, что бы я ни старался, что-то всегда с ним не так, и это сводит меня с ума.
Сложно! О. Но рад, что ты смог заставить его работать! – kcoppock