androidballoonyandex-maps

Yandex mapkit android balloon set text color


In example of using yandexmapkit library called "yandexmapkit-sample" which I get from https://github.com/yandexmobile/yandexmapkit-android, when I started any example that have Balloon in it's code, text color and background color of Balloon are the same.

Can I change these colors somehow?

Overlay overlay = new Overlay(mMapController);
OverlayItem kremlin = new OverlayItem(new GeoPoint(55.752004 , 37.617017), res.getDrawable(R.drawable.kreml));
BalloonItem balloonKremlin = new BalloonItem(this,kremlin.getGeoPoint());
balloonKremlin.setText("Московский Кремль. Здесь можно ещё много о чём написать.");
balloonKremlin.setOnBalloonListener(this);
kremlin.setBalloonItem(balloonKremlin);
overlay.addOverlayItem(kremlin); 

Solution

  • Yes, it's possible: just create layout named ymk_balloon_default_layout.xml in your project and set color in there.

    Something like this:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:orientation="horizontal"
                  android:background="@drawable/ymk_balloon_black"
            >
        <TextView xmlns:android="http://schemas.android.com/apk/res/android"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:id="@+id/ymk_balloon_text_view"
                  android:gravity="fill_horizontal"
                  android:ellipsize="end"
                  android:singleLine="false"
                  android:textSize="18dip"
                  android:text="    "
                  android:textColor="@color/your_color_here"
                />
    </LinearLayout>
    

    See MapKit sources.