首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android :如何处理相对布局

Android :如何处理相对布局
EN

Stack Overflow用户
提问于 2012-09-27 14:05:25
回答 2查看 223关注 0票数 1

我被困了两天,相对layout..here是我的线性布局的屏幕截图

所以这很好。但是现在我想在地图上的某个地方添加刷新按钮,但我发现使用线性布局是不可能的。所以我尝试了相对布局,但无法得到如上的屏幕。我的页脚布局总是显示在顶部。下面是我的xml代码

代码语言:javascript
复制
<?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>

任何帮助都将不胜感激。提前感谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-09-27 14:19:55

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

代码语言:javascript
复制
<?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>

希望这能帮到你...!

票数 2
EN

Stack Overflow用户

发布于 2012-09-27 14:11:51

RelativeLayout可能就是您想要的。这可能很难编程,因为您需要首先定义底部视图,然后定义屏幕上位于其上方的视图。

有关使用RelativeLayouts的更多帮助,请查看these tutorials。最好的学习方法就是实践!尝试各种布局,直到你弄清楚规则是如何工作的。那么将其重新创建为RelativeLayout应该是相当简单的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12615031

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档