Search code examples
androidxmlandroid-layoutandroid-linearlayout

Linear Layout Embeded in Another Linear Layout


I'm trying to embed a linear layout in another linear layout. I have a map view. If I put embeded layout AFTER mapview it does not work. If I put it BEFORE it does? Why and what should I do?

Two files given below: first one fail. second one works? I want the first one though.

<!--two files.  

The first file does not work.  The Check Boxes in an embeded linear layout is below the mapview.  It only shows map view.  

The second file works.  The Check Boxes in an embeded linear layout is ABOVE the mapview.-->

<!-- FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE-->

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" 
    android:background="#A971E5" >


    <com.google.android.maps.MapView
        android:id="@+id/mapWhenImClose"    
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true"
        android:apiKey="0MbR34udiEJdnkplC1F7rK4ZxbSFzdRagCruFDA"/>
        <!--  had this line but it said depreciated        
        android:enabled="true" -->

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:orientation="horizontal">

        <CheckBox
            android:id="@+id/chkShowStreetView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/strShowStreetView" />

        <CheckBox
            android:id="@+id/chkShowSatelliteView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/strShowSatelliteView" />

    </LinearLayout>



</LinearLayout>


<!--File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two-->


<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" 
    android:background="#A971E5" >


    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:orientation="horizontal">

        <CheckBox
            android:id="@+id/chkShowStreetView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/strShowStreetView" />

        <CheckBox
            android:id="@+id/chkShowSatelliteView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/strShowSatelliteView" />

    </LinearLayout>


    <com.google.android.maps.MapView
        android:id="@+id/mapWhenImClose"    
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true"
        android:apiKey="0MbR34udiEJdnkplC1F7rK4ZxbSFzdRagCruFDA"/>
        <!--  had this line but it said depreciated        
        android:enabled="true" -->

</LinearLayout>

http://pastebin.com/Tfsec1Mh


Solution

  • Your MapView covers the whole screen with android:layout_height="fill_parent":

    <com.google.android.maps.MapView
            android:id="@+id/mapWhenImClose"    
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:clickable="true"
            android:apiKey="0MbR34udiEJdnkplC1F7rK4ZxbSFzdRagCruFDA"/>
            <!--  had this line but it said depreciated        
            android:enabled="true" -->
    

    Edit:

    <?xml version="1.0" encoding="utf-8"?>
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#A971E5" >
    
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:orientation="horizontal"
            android:id="@+id/thebar" 
            android:layout_alignParentBottom="true">
    
            <CheckBox
                android:id="@+id/chkShowStreetView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/strShowStreetView" />
    
            <CheckBox
                android:id="@+id/chkShowSatelliteView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/strShowSatelliteView" />
    
        </LinearLayout>
    
    
        <com.google.android.maps.MapView
            android:id="@+id/mapWhenImClose"    
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentTop="true"
            android:layout_above="@id/thebar"
            android:clickable="true"
            android:apiKey="0MbR34udiEJdnkplC1F7rK4ZxbSFzdRagCruFDA"/>
            <!--  had this line but it said depreciated        
            android:enabled="true" -->
    
    </RelativeLayout>