LoginSignup
2
2

More than 5 years have passed since last update.

GoogleMaps v2でGoogleのロゴの位置を変更する

Posted at

スクリーンショット 2013-12-29 0.28.35.png

GoogleMaps v2でGoogleのログを移動する

上図のように、Map上に何らかのオブジェクトを追加や半透明な何かをオーバーレイしたい場合、
Googleのロゴが隠れないように工夫する必要があります。
このロゴの動かし方がiOSとAndroidで違うので、Android版を備忘録も兼ねて。

GoogleMapオブジェクトにpaddingを付ける

もはやタイトルだけで全てを表した様なものですが、GoogleMapオブジェクトにpaddingを付ける事によってロゴが動きます。
公式にもよく見ると書いてあるので公式よく見ろって話しなんですが。

実際には、onGlobalLayoutの後にでもpaddingを指定してあげればいい感じになります。

view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                int height = hoge.getHeight();
                map.setPadding(0, 0, 0, height);
                view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }
        });

余談ですが、viewTreeObserverは取得し直さないとぬるぽで怒られるようなのでその辺りも要注意。

2
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2