I have a layout with 6 included layouts in a TableLayout. I want to do this in landscape mode, because a ScrollView would be awkward in my scenario.
I have a 48dp-high horizontal layout, which contains a square ImageView, a SeekBar with full weight, and a square ImageButton. I set the drawables for the ImageView in Java.
In the main layout, I use an include for each one and I am trying to even out the columns, because they only take up half the screen, by the way this is an activity with Theme.Holo.Dialog as its theme.
However, when I run the app, I get a 40-60% unbalanced view. Why? What am I doing wrong?
Part of layout-land/main.xml
<LinearLayout
xmlns:android="http://ift.tt/nIICcg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
... >
...
<TableLayout
android:layout_width="match_parent"
android:layout_weight="1"
android:stretchColumns="1"
android:layout_height="wrap_content">
<TableRow android:layout_width="match_parent" android:layout_height="wrap_content">
<include android:layout_weight="1" layout="@layout/toast_item" android:id="@+id/systemToast"/>
<include android:layout_weight="1" layout="@layout/toast_item" android:id="@+id/ringerToast"/>
</TableRow>
<TableRow android:layout_width="match_parent" android:layout_height="wrap_content">
<include android:layout_weight="1" layout="@layout/toast_item" android:id="@+id/notifyToast"/>
<include android:layout_weight="1" layout="@layout/toast_item" android:id="@+id/mediaToast"/>
</TableRow>
<TableRow android:layout_width="match_parent" android:layout_height="wrap_content">
<include android:layout_weight="1" layout="@layout/toast_item" android:id="@+id/alarmToast"/>
<include android:layout_weight="1" layout="@layout/toast_item" android:id="@+id/inCallToast"/>
</TableRow>
</TableLayout>
...
</LinearLayout>
layout-land/toast_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:id="@+id/icon"
android:src="@drawable/ic_audio_alarm"
android:layout_width="48dp"
android:layout_height="48dp"
android:scaleType="center"
android:clickable="false"
android:layout_weight="0"/>
<SeekBar
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:layout_marginLeft="4dp"
android:maxHeight="1000dp"
android:layout_marginRight="4dp"
android:id="@+id/seekbar"/>
<ImageButton
android:id="@+id/schedules"
android:layout_width="48dp"
android:layout_height="match_parent"
android:scaleType="center"
android:layout_weight="0"
android:src="@drawable/ic_action_event"
android:background="?android:attr/selectableItemBackground"
/>
</LinearLayout>
No comments:
Post a Comment