Possible duplicate of Linear Layout and weight in Android
Hi,
I have strange issue. I have designed a custom widget that has linear layout with three buttons. It's code is like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3" >
<ToggleButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/tbBrowse"
android:background="@drawable/btn_tg_browse"
android:textOn=""
android:textOff=""
android:focusable="false"
android:focusableInTouchMode="false"
android:checked="false"
android:gravity="bottom"/>
<ToggleButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/tbHotSpot"
android:background="@drawable/btn_tg_hotspot"
android:textOn=""
android:textOff=""
android:focusable="false"
android:focusableInTouchMode="false"
android:checked="true"
android:gravity="bottom"/>
<ToggleButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/tbMatches"
android:background="@drawable/btn_tg_matches"
android:textOn=""
android:textOff=""
android:focusable="false"
android:focusableInTouchMode="false"
android:checked="false"
android:gravity="bottom"/>
</LinearLayout>
It's look and feel is like this which seems okay:
I have added this widget to my class (android:id="@+id/Footer"):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/White">
<view
android:layout_width="match_parent"
android:layout_height="wrap_content"
class="com.belldigital.widget.HeaderBar"
android:id="@+id/Header"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />
<view
android:layout_width="match_parent"
android:layout_height="wrap_content"
class="com.belldigital.widget.FooterBar"
android:id="@+id/Footer"
android:layout_alignParentBottom="true" />
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/Header"
android:layout_above="@id/Footer"/>
</RelativeLayout>
Since, no gravity is defined in 'view' declaration I expect to see same look and feel like first image but I see following image in both emulator and real device.
What you think? It might be okay if I redesign my widget based on Relative layout. However, I thing current design is okay but why 'view' widget disorder my arrangement? Any comment/suggestion would be appreciated.