2012-05-19 4 views
0

Я пытаюсь внедрить линейный макет в другую линейную компоновку. У меня есть вид карты. Если я поместил встроенный макет ПОСЛЕ просмотра карты, он не сработает. Если я сделаю это до того, как это произойдет? Почему и что мне делать?Линейный макет, встроенный в другую линейную компоновку

Два файла, приведенные ниже: первый сбой. второй работает? Я хочу первый, хотя.

<!--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

+0

Логически это кажется 'MapView' принимает до полного экран, потому что вы ve 'android: layout_height =" fill_parent "', и это вынуждает 'LinearLayout' выходить из нижней части экрана. Что произойдет, если вы установите его высоту на 'wrap_content'? В качестве альтернативы поместите «MapView» в собственный «LinearLayout», установите высоту этого значения в 0dp и то же самое для «LinearLayout», который содержит «CheckBoxes». Затем установите «android: layout_weight» на каждом, чтобы выделить часть экрана. – Squonk

+0

Извините, только это заметило ... плохо сыграйте с этим подходом ... моя главная цель прямо сейчас - это узнать больше, чем просто получить что-то из двери. –

ответ

1

Ваш MapView охватывает весь экран с 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> 
+0

Спасибо за ответ. Я думаю, что это правильное направление, однако, когда я делаю это изменение, я замечаю, что в дизайнере карта становится тонкой лентой. Когда я запускаю его в AVD, он выглядит одинаково (карта занимает экран и не видит флажки). –

+0

Могу ли я добавить к этому скриншот? Я ничего не вижу, чтобы загрузить файл. –

+0

Я понимаю галочку для правильного ответа, но каковы цифры вверх/вниз? –