简体   繁体   中英

Mapsforge add button to Mapview

I am working on an Android App for skier and snowboarder which should navigate the user from one point to another.

To show the map I am using Mapsforge-Version 0.4.0.

On the map I have added some layers and now I want to add an Imagebutton but all attempts failed. Do you have some ideas how to do that without an Xml-File?

I am new and it is my first question, so if I have forget some information please let me know.

STEP 1 : avoid setting content view to mapView

   // setContentView(mapView);


STEP 2 : add your button to a linearlayout
simply add your linearlayout to a relativelayout

<RelativeLayout
    android:id="@+id/rlMap"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <LinearLayout
        android:id="@+id/llControls"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true">

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="New Button"
            android:id="@+id/button" />

    </LinearLayout>

</RelativeLayout>

STEP 3 : Find your RelativeLayout and add your mapView Object to it

RelativeLayout rlMap = (RelativeLayout) findViewById(R.id.rlMap);
rlMap.addView(mapView,0);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM