我被相对布局卡住了两天..这是我的线性布局屏幕截图
所以很好。但现在我想在 map 上的某个地方添加刷新按钮,但我发现线性布局是不可能的。所以我尝试了相对布局,但甚至无法获得上面的屏幕。 我的页脚布局总是显示在顶部。这是我的 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>
任何帮助将不胜感激。提前致谢
最佳答案
试试这个。使用框架布局并将 map View 和按钮放在框架布局内。因此按钮将放置在 map View 上方。根据需要放置。
<?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>
希望这有助于...!!!
关于安卓 : how to deal with relative layout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12615031/