2012-09-09 22 views
0

我无法让布局为此工作。MapView和自动完成无法让布局工作

我有这个布局工作正常一个MapView:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:id="@+id/rel_layout_mapview"> 

<org.osmdroid.views.MapView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/mapview" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:clickable="true" 
    /> 

<ImageView android:id="@+id/drag" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:src="@drawable/ss_pin" 
android:visibility="gone" 
/> 

没有问题,但只要我设法得到它上面的自动完成,这是行不通的。

<?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" 
> 

<AutoCompleteTextView android:id="@+id/autocomplete_country" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    /> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:id="@+id/rel_layout_mapview"> 

<org.osmdroid.views.MapView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/mapview" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:clickable="true" 
    /> 

<ImageView android:id="@+id/drag" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:src="@drawable/ss_pin" 
android:visibility="gone" 
/> 

</RelativeLayout> 

</LinearLayout> 

有人可以指出我如何使用mapview和上面的自动完成功能做一个布局的正确方向。 mapview必须位于它的OWN相对视图中,因为我有很多特定的代码来重新计算mapview的父级。

谢谢!

回答

0

我可以简单地通过设置边距来解决它。

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
     android:layout_height="50dip" > 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <AutoCompleteTextView 
     android:id="@+id/locationsearch2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:hint="Enter zipcode or address" 
     tools:context=".AutoCompleteDynamic" /> 

</RelativeLayout> 

    </LinearLayout> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:id="@+id/rel_layout_mapview" 
    android:layout_marginTop="50dip"> 

    <org.osmdroid.views.MapView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/mapview" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:clickable="true" 
     /> 

<ImageView android:id="@+id/drag" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/ss_pin" 
    android:visibility="gone" 
    /> 
</RelativeLayout> 

</FrameLayout>