Search code examples
androidgoogle-maps-api-2google-maps-android-api-2

Add seek bar on map using Map API V2 in android


I am working on a application in which i am using Google Map Api V2, the map is successfully loaded, also i have put markers on it but now when i tried to add a seek bar on my map its not showing it on map's surface, actually i want to give a feature in which a user can increase and decrease the radius of circle using seek bar, but when i add that seek bar through XML its not showing me the seek bar,

my XML is like that :-

<RelativeLayout 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"
    tools:context=".MainActivity" >

    <RadioGroup
        android:id="@+id/rg_views"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <RadioButton
            android:id="@+id/rb_normal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="StreetView" />

        <RadioButton
            android:id="@+id/rb_satellite"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Satellite" />

        <RadioButton
            android:id="@+id/rb_terrain"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Terrian" />
    </RadioGroup>

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/rg_views" >

        <fragment
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/map"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            class="com.google.android.gms.maps.SupportMapFragment" />

        <SeekBar
            android:id="@+id/bar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:layout_marginRight="-30dp"
            android:max="400"
            android:minWidth="100dp"
            android:progress="100"
            android:rotation="270" />
    </RelativeLayout>

</RelativeLayout>

if anyone knows how to place button, seek bar on map's surface then please help me

thanks


Solution

  • The SeekBar is made for being horizontal. Rotating it will make problems for it to show properly without code modification. You can try examples of vertical SeekBar implementations, but non of them worked for me well.

    How can I get a working vertical SeekBar in Android?

    http://hackskrieg.wordpress.com/2012/04/20/working-vertical-seekbar-for-android/