2012-09-27 68 views
1

我两天前的坚持与相对layout..here我是线性布局enter image description here安卓:如何应对相对布局

所以它的精细我的屏幕快照。但现在我想在地图上的某个地方添加刷新按钮,但是我发现它不可能具有线性布局。所以我试图在相对布局,但不能甚至得到如上屏幕。 我的页脚布局始终在顶部显示。这里是我的XML代码

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

<!-- include title bar for all screen --> 

<include 
    android:id="@+id/include1" 
    layout="@layout/titlebar_layout" /> 


<com.google.android.maps.MapView 
    android:id="@+id/map" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1.63" 
    android:apiKey="0VkXbAOFvAq7b6uaGHSmnS2a2VosPxoS6ceHY_g" 
    android:clickable="true" > 
</com.google.android.maps.MapView> 

<include 
    android:id="@+id/include2" 
    android:layout_marginBottom="38dp" 
    layout="@layout/bottom_layout"/> 

</LinearLayout> 

任何帮助将不胜感激。在此先感谢

+0

你在哪里想要把刷新按钮? – Renjith

+0

感谢reply..i希望把它在MapView的 –

回答

2

试试这个。使用框架布局并将框架布局中的地图视图和按钮放入。因此按钮将被放置在地图视图上方。根据您的需要放置它。

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

<!-- include title bar for all screen --> 

<include 
    android:id="@+id/include1" 
    layout="@layout/titlebar_layout" /> 


<FrameLayout android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_width="1.0" > 

    <com.google.android.maps.MapView 
     android:id="@+id/map" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1.63" 
     android:apiKey="0VkXbAOFvAq7b6uaGHSmnS2a2VosPxoS6ceHY_g" 
     android:clickable="true" > 
    </com.google.android.maps.MapView> 

    <Button android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="right" /> 

</FrameLayout> 

<include 
    android:id="@+id/include2" 
    android:layout_marginBottom="38dp" 
    layout="@layout/bottom_layout"/> 

</LinearLayout> 

希望这有助于...... !!!

0

RelativeLayout的可能是你想要的东西。它可以是难以编程,因为你需要定义底部查看第一,然后落入其上方屏幕上的视图。

退房thesetutorials有关使用RelativeLayouts一些更多的援助。学习的最好方法就是这样做!尝试各种布局,直到找出规则的工作方式。然后,将它重新创建为RelativeLayout应该非常简单。

+0

谢谢哥们你suggestion..i的右上角将再次尝试从scratch..thanks –