簡體   English   中英

Skobbler標注尾部imageview顯示錯誤Android SDK 2.5.1

[英]Skobbler callout tail imageview displayed incorrectly Android SDK 2.5.1

我有一些代碼,它添加了一個自定義注釋標注視圖,只要在我的Skobbler mapview中選擇了注釋,就會顯示該視圖。

@Override
public void onAnnotationSelected(final SKAnnotation annotation) {
  ...
  mapPopup = mapHolder.getCalloutView();
  // set the callout view’s background color
  mapPopup.setViewColor(Color.WHITE);
  View view = getLayoutInflater().inflate(R.layout.map_callout, null);
  ...
  mapPopup.setCustomView(view);
  // setting 2nd parameter to 'true' will cause tail to be displayed
  mapPopup.showAtLocation(annotation.getLocation(), true);
  ...
}

我還在showAtLocation()調用中請求使用“tail”imageview顯示callout視圖。 但是,當我在應用程序中測試時,我看到尾部出現在我的map_surface_holder RelativeLayout容器的頂部,而不是顯示callout彈出視圖的FrameLayout容器的底部。

圖像顯示錯誤定位的尾部圖像視圖

當我平移地圖時,我可以看到尾部視圖相對於標注視圖的移動向左和向右移動,但它仍然與map_surface_holder容器的頂部對齊,從不向上或向下移動。

我是否需要在某處添加一些代碼以使尾部圖像視圖知道它應該放置在RelativeLayout容器的y軸方向的哪個位置?

我確實嘗試添加對mapPopup.setVerticalOffset(offset)的調用以查看它是否有任何效果,但尾部圖像仍然鎖定在屏幕頂部。

我在自定義標注視圖和Skobbler提供的默認視圖之間可以看到的另一個區別是標准視圖是RelativeLayout容器,而我的實現是FrameLayout。 但是,我不確定它是否重要,因為這里的Tail ImageView被添加到我的標注視圖的父級,而不是作為孩子。

提前感謝您對此事的任何幫助,如果有任何其他細節會有所幫助,請告訴我。

謝謝!

我們試圖用2.5.1和3.X重現這個問題 - 但是我們無法解決。

這是我們使用的代碼:

//MapActivity
    @Override
    onCreate(Bundle savedInstanceState)
    {
    …
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mapPopup = mapViewGroup.getCalloutView();
    View view = inflater.inflate(R.layout.layout_popup, null);
    popupTitleView = (TextView) view.findViewById(R.id.top_text);
    popupDescriptionView = (TextView) view.findViewById(R.id.bottom_text);
    mapPopup.setCustomView(view);
    …
    }

@Override
public void onAnnotationSelected(final SKAnnotation annotation) {
    if (navigationUI.getVisibility() == View.VISIBLE) {
        return;
    }
    // show the popup at the proper position when selecting an
    // annotation
    int annotationHeight = 0;
    float annotationOffset = annotation.getOffset().getY();
    switch (annotation.getUniqueID()) {
        case 10:
            annotationHeight =(int) (64 * getResources().getDisplayMetrics().density);
            popupTitleView.setText("Annotation using  texture ID ");
            popupDescriptionView.setText(null);
            break;
        case 11:
            annotationHeight = customView.getHeight();
            popupTitleView.setText("Annotation using custom view");
            popupDescriptionView.setText(null);
            break;
    }
    mapPopup.setVerticalOffset(-annotationOffset + annotationHeight / 2);
    mapPopup.showAtLocation(annotation.getLocation(), true);
}

//layout_popup.xml

<ImageView
    android:id="@+id/left_image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:clickable="true"
    android:padding="5dp"
    android:src="@drawable/icon_map_popup_navigate" />

<LinearLayout
    android:id="@+id/mid_layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_toRightOf="@id/left_image"
    android:orientation="vertical"
    android:paddingBottom="5dp"
    android:paddingRight="5dp"
    android:paddingTop="5dp"
    android:weightSum="1" >

    <TextView
        android:id="@+id/top_text"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="Title text"
        android:textColor="@color/black"
        android:textSize="18dp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/bottom_text"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:gravity="center"
        android:linksClickable="true"
        android:text="Subtitle text"
        android:textColor="@color/black"
        android:textSize="14dp" />
</LinearLayout>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM