В настоящее время я делаю специальную xml-разметку горизонтального экрана, где присутствуют 4 изображения, а 2 LinearLayouts расположены рядом друг с другом по 2 изображения в каждом. Эти LinearLayouts я называю linearLayout1
и linearLayout2
.
linearLayout1
отмечен синим прямоугольником:
linearLayout2
отмечен синим прямоугольником:
Как видите, первый использует ~80% экрана, а второй использует что осталось. Я не хочу этого, конечно, я хочу по 50% за каждого. Я не могу использовать layout_weight
, потому что он уже используется в самих LinearLayouts (позиционирование двух изображений), а вложенные веса плохо влияют на производительность.
Я пробовал много разных вариантов, но просто не могу заставить два LinearLayouts занимать по 50% экрана каждый. Вот код:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/db1_root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/title_container"
style="@style/TitleBar" >
<ImageView
style="@style/TitleBarLogo"
android:contentDescription="@string/imgViewDesc"
android:src="@drawable/title_logo" />
<ImageView
style="@style/TitleBarSeparator"
android:contentDescription="@string/imgViewDesc" />
<TextView style="@style/TitleBarText" />
<ImageButton
style="@style/TitleBarAction"
android:contentDescription="@string/imgViewDesc"
android:onClick="onClickAbout"
android:src="@drawable/title_about" />
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/title_container"
android:layout_above="@+id/mobFoxView" >
<!-- LEFT COLUMN -->
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/mobFoxView"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/linearLayout2"
android:background="@color/white"
android:gravity="center"
android:orientation="vertical"
android:weightSum="2" >
<ImageView
android:id="@+id/imgNews"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:contentDescription="@string/imgViewDesc"
android:onClick="onClickFeature"
android:src="@drawable/front_news_1" />
<ImageView
android:id="@+id/imgReleases"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:contentDescription="@string/imgViewDesc"
android:onClick="onClickFeature"
android:src="@drawable/front_releases_1" />
</LinearLayout>
<!-- RIGHT COLUMN -->
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_above="@+id/mobFoxView"
android:layout_alignParentRight="true"
android:layout_alignTop="@id/linearLayout1"
android:background="@color/white"
android:gravity="center"
android:orientation="vertical"
android:weightSum="2" >
<ImageView
android:id="@+id/imgArtists"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:contentDescription="@string/imgViewDesc"
android:onClick="onClickFeature"
android:src="@drawable/front_artists_1" />
<ImageView
android:id="@+id/imgLabels"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:contentDescription="@string/imgViewDesc"
android:onClick="onClickFeature"
android:src="@drawable/front_labels_1" />
</LinearLayout>
</RelativeLayout>
<com.mobfox.sdk.MobFoxView
android:id="@+id/mobFoxView"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
mode="test"
publisherId="@string/mobFoxID" />
</RelativeLayout>