首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在活动地图中添加按钮?

如何在活动地图中添加按钮?
EN

Stack Overflow用户
提问于 2015-03-15 21:17:40
回答 2查看 1K关注 0票数 1

当我创建项目时,我选择了Google活动,如何在布局中添加按钮?抱歉,如果这是个愚蠢的问题,我是刚加入Android的。

代码语言:javascript
复制
<Button
        android:id="@+id/btn_draw_State"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_gravity="right|top"
        android:layout_marginTop="55dp"
        android:layout_marginRight="11dp" />

布局:

代码语言:javascript
复制
<fragment
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" android:id="@+id/map" tools:context=".MapsActivityWifi"
android:name="com.google.android.gms.maps.SupportMapFragment">
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-03-15 21:58:13

来自StackOverFlow PT

代码语言:javascript
复制
<FrameLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <fragment 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/map"
        tools:context=".MapsActivityWifi"
        android:name="com.google.android.gms.maps.SupportMapFragment"/>

    <Button
        android:id="@+id/btn_draw_State"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_gravity="right|top"
        android:layout_marginTop="55dp"
        android:layout_marginRight="11dp" />
</FrameLayout>

没有地图吗?

票数 0
EN

Stack Overflow用户

发布于 2015-03-15 21:33:16

FrameLayout旨在屏蔽屏幕上的一个区域,以显示单个item.Use、LinearLayoutRelativeLayout

试一试,并根据自己的意愿更改按钮属性。

代码语言:javascript
复制
        <RelativeLayout
       xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:tools="http://schemas.android.com/tools">

<fragment 
    android:layout_width="match_parent"
    android:layout_height="instead of match parent try to give a value so that it does not occupy the whole screen"
    android:id="@+id/map"
    tools:context=".MapsActivityWifi"
    android:name="com.google.android.gms.maps.SupportMapFragment"/>

<Button
    android:id="@+id/btn_draw_State"
    android:layout_below="@id/map"
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:layout_gravity="right|top"
    android:layout_marginTop="55dp"
    android:layout_marginRight="11dp" />

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

https://stackoverflow.com/questions/29066289

复制
相关文章

相似问题

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