summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindowView.java
blob: d1a59aae4e880998d092b4a54dd171337f979dd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.mapbox.mapboxsdk.annotations;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.RelativeLayout;

import com.mapbox.mapboxsdk.R;

class InfoWindowView extends RelativeLayout {

  private InfoWindowTipView mTipView;

  public InfoWindowView(Context context) {
    this(context, null);
  }

  public InfoWindowView(Context context, AttributeSet attrs) {
    this(context, attrs, 0);
  }

  public InfoWindowView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    initialize(context);
  }

  private void initialize(Context context) {
    LayoutInflater.from(context).inflate(R.layout.mapbox_infowindow_content, this);
    mTipView = (InfoWindowTipView) findViewById(R.id.infowindow_tipview);
  }

  void setTipViewMarginLeft(int marginLeft) {
    RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mTipView.getLayoutParams();
    layoutParams.leftMargin = marginLeft;
    // This is a bit of a hack but prevents an occasional gap between the InfoWindow
    layoutParams.topMargin = (int) getResources().getDimension(R.dimen.mapbox_infowindow_offset);
  }
}