Example usage for android.graphics.drawable Drawable getIntrinsicHeight

List of usage examples for android.graphics.drawable Drawable getIntrinsicHeight

Introduction

In this page you can find the example usage for android.graphics.drawable Drawable getIntrinsicHeight.

Prototype

public int getIntrinsicHeight() 

Source Link

Document

Returns the drawable's intrinsic height.

Usage

From source file:com.meiqia.meiqiasdk.third.photoview.PhotoViewAttacher.java

/**
 * Calculate Matrix for FIT_CENTER//w  w w . j a  v  a 2s .c o m
 *
 * @param d - Drawable being displayed
 */
protected void updateBaseMatrix(Drawable d) {
    ImageView imageView = getImageView();
    if (null == imageView || null == d) {
        return;
    }

    final float viewWidth = getImageViewWidth(imageView);
    final float viewHeight = getImageViewHeight(imageView);
    final int drawableWidth = d.getIntrinsicWidth();
    final int drawableHeight = d.getIntrinsicHeight();

    mBaseMatrix.reset();

    final float widthScale = viewWidth / drawableWidth;
    final float heightScale = viewHeight / drawableHeight;

    if (mScaleType == ScaleType.CENTER) {
        mBaseMatrix.postTranslate((viewWidth - drawableWidth) / 2F, (viewHeight - drawableHeight) / 2F);

    } else if (mScaleType == ScaleType.CENTER_CROP) {
        float scale = Math.max(widthScale, heightScale);
        mBaseMatrix.postScale(scale, scale);
        mBaseMatrix.postTranslate((viewWidth - drawableWidth * scale) / 2F,
                (viewHeight - drawableHeight * scale) / 2F);

    } else if (mScaleType == ScaleType.CENTER_INSIDE) {
        float scale = Math.min(1.0f, Math.min(widthScale, heightScale));
        mBaseMatrix.postScale(scale, scale);
        mBaseMatrix.postTranslate((viewWidth - drawableWidth * scale) / 2F,
                (viewHeight - drawableHeight * scale) / 2F);

    } else {
        RectF mTempSrc = new RectF(0, 0, drawableWidth, drawableHeight);
        RectF mTempDst = new RectF(0, 0, viewWidth, viewHeight);

        if ((int) mBaseRotation % 180 != 0) {
            mTempSrc = new RectF(0, 0, drawableHeight, drawableWidth);
        }

        switch (mScaleType) {
        case FIT_CENTER:
            mBaseMatrix.setRectToRect(mTempSrc, mTempDst, ScaleToFit.CENTER);
            break;

        case FIT_START:
            mBaseMatrix.setRectToRect(mTempSrc, mTempDst, ScaleToFit.START);
            break;

        case FIT_END:
            mBaseMatrix.setRectToRect(mTempSrc, mTempDst, ScaleToFit.END);
            break;

        case FIT_XY:
            mBaseMatrix.setRectToRect(mTempSrc, mTempDst, ScaleToFit.FILL);
            break;

        default:
            break;
        }
    }

    resetMatrix();
}

From source file:com.landenlabs.all_devtool.IconBaseFragment.java

/**
 * Display icon (drawable) information// www. j  av  a 2s  .  c om
 *
 * @param iconInfo
 */
private void showIconDialog(IconInfo iconInfo) {
    Drawable iconD = iconInfo.getDrawable();
    String iconType = iconD.getClass().getSimpleName();

    LayoutInflater inflater = m_context.getLayoutInflater();
    final View dialogLayout = inflater.inflate(R.layout.icon_dlg, null);

    View shareBtn = dialogLayout.findViewById(R.id.icon_dlg_share);
    shareBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Utils.shareScreen(dialogLayout, "iconDetail", null);
        }
    });

    final TextView imageName = Ui.viewById(dialogLayout, R.id.icon_dlg_name);
    final TextView imageSize = Ui.viewById(dialogLayout, R.id.icon_dlg_size);
    final TextView imageType = Ui.viewById(dialogLayout, R.id.icon_dlg_type);
    final TextView imageExtra = Ui.viewById(dialogLayout, R.id.icon_dlg_extra);

    imageName.setText(iconInfo.fieldStr());
    imageSize.setText(String.format("Size: %d x %d", iconD.getIntrinsicWidth(), iconD.getIntrinsicHeight()));
    imageType.setText(iconType);

    final ImageView imageView = Ui.viewById(dialogLayout, R.id.icon_dlg_image);
    // imageView.setImageDrawable(iconD);
    boolean hasStates = iconD.isStateful();

    final View stateTitle = dialogLayout.findViewById(R.id.icon_dlg_state_title);
    stateTitle.setVisibility(hasStates ? View.VISIBLE : View.GONE);

    final TableRow row1 = Ui.viewById(dialogLayout, R.id.icon_dlg_state_row1);
    row1.removeAllViews();

    final TableRow row2 = Ui.viewById(dialogLayout, R.id.icon_dlg_state_row2);
    row2.removeAllViews();

    boolean showRows = false;
    String extraInfo = "";

    if (hasStates) {
        extraInfo = "StateFul";
        showRows = true;

        StateListDrawable stateListDrawable = (StateListDrawable) iconD;
        Set<Drawable> stateIcons = new HashSet<Drawable>();
        showStateIcon(imageView, row1, row2, stateListDrawable, android.R.attr.state_enabled, "Enabled",
                stateIcons);
        showStateIcon(imageView, row1, row2, stateListDrawable, android.R.attr.state_pressed, "Pressed",
                stateIcons);
        showStateIcon(imageView, row1, row2, stateListDrawable, android.R.attr.state_checked, "Checked",
                stateIcons);
        showStateIcon(imageView, row1, row2, stateListDrawable, android.R.attr.state_selected, "Selected",
                stateIcons);
    }

    if (iconType.equals(LayerDrawable.class.getSimpleName())) {
        showRows = true;
        LayerDrawable layerDrawable = (LayerDrawable) iconD;
        int layerCnt = layerDrawable.getNumberOfLayers();
        extraInfo = String.format(Locale.getDefault(), "Layers:%d", layerCnt);
        for (int layerIdx = 0; layerIdx < Math.min(layerCnt, 3); layerIdx++) {
            showLayerIcon(imageView, row1, row2, layerDrawable.getDrawable(layerIdx), layerIdx);
        }
    } else if (iconType.equals(AnimationDrawable.class.getSimpleName())) {
        final AnimationDrawable animationDrawable = (AnimationDrawable) iconD;
        extraInfo = String.format(Locale.getDefault(), "Frames:%d", animationDrawable.getNumberOfFrames());
        showRows = true;
        showAnimationBtns(imageView, animationDrawable, row1, row2);

        // Can't control animation at this time, drawable not rendered yet.
        // animationDrawable.stop();
    }

    row1.setVisibility(showRows ? View.VISIBLE : View.GONE);
    row2.setVisibility(showRows ? View.VISIBLE : View.GONE);

    imageExtra.setText(extraInfo);
    imageView.setImageDrawable(iconD);

    dialogLayout.findViewById(R.id.icon_dlg_whiteBtn).setOnClickListener(new View.OnClickListener() {
        @SuppressWarnings("deprecation")
        @Override
        public void onClick(View v) {
            imageView.setBackgroundDrawable(v.getBackground());
        }
    });

    dialogLayout.findViewById(R.id.icon_dlg_grayBtn).setOnClickListener(new View.OnClickListener() {
        @SuppressWarnings("deprecation")
        @Override
        public void onClick(View v) {
            imageView.setBackgroundDrawable(v.getBackground());
        }
    });

    dialogLayout.findViewById(R.id.icon_dlg_blackBtn).setOnClickListener(new View.OnClickListener() {
        @SuppressWarnings("deprecation")
        @Override
        public void onClick(View v) {
            imageView.setBackgroundDrawable(v.getBackground());
        }
    });

    dialogLayout.findViewById(R.id.icon_dlg_squaresBtn).setOnClickListener(new View.OnClickListener() {
        @SuppressWarnings("deprecation")
        @Override
        public void onClick(View v) {
            imageView.setBackgroundDrawable(v.getBackground());
        }
    });

    AlertDialog.Builder builder = new AlertDialog.Builder(m_context);
    builder.setView(dialogLayout);

    builder.setMessage("Icon").setCancelable(false).setPositiveButton("Close",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // if this button is clicked, close
                    dialog.cancel();
                }
            });

    builder.show();
}

From source file:io.apptik.widget.MultiSlider.java

/**
 * @param gap If set to {@link Integer#MIN_VALUE}, this will be ignored and
 *///  w  w  w.j  a v  a 2s  . c  o m
private void setThumbPos(int w, int h, Drawable thumb, Drawable prevThumb, Drawable range, float scale, int gap,
        int thumbOffset, int optThumbOffset) {
    final int available = getAvailable();
    int thumbWidth = thumb.getIntrinsicWidth();
    int thumbHeight = thumb.getIntrinsicHeight();

    //todo change available before also

    float scaleOffset = getScaleSize() > 0 ? (float) mScaleMin / (float) getScaleSize() : 0;

    int thumbPos = (int) (scale * available - scaleOffset * available + 0.5f);

    int topBound, bottomBound;
    if (gap == Integer.MIN_VALUE) {
        Rect oldBounds = thumb.getBounds();
        topBound = oldBounds.top;
        bottomBound = oldBounds.bottom;
    } else {
        topBound = gap;
        bottomBound = gap + thumbHeight;
    }

    // Canvas will be translated, so 0,0 is where we start drawing
    final int left = (isLayoutRtl() && mMirrorForRtl) ? available - thumbPos - optThumbOffset
            : thumbPos + optThumbOffset;

    thumb.setBounds(left, topBound, left + thumbWidth, bottomBound);

    w -= getPaddingRight() + getPaddingLeft();
    h -= getPaddingTop() + getPaddingBottom();

    int right = w;
    int bottom = h;

    int leftRange = 0;
    if (prevThumb != null) {
        leftRange = prevThumb.getBounds().left;
    }
    if (range != null) {
        range.setBounds(leftRange, 0, left, bottom);
    }

    invalidate();
}

From source file:com.mooc.viewpage_photoview_circleindicator.photoview.PhotoViewAttacher.java

/**
 * Calculate Matrix for FIT_CENTER// w ww  .  j av a  2  s.  co m
 *
 * @param d - Drawable being displayed
 */
private void updateBaseMatrix(Drawable d, boolean isFirst) {
    ImageView imageView = getImageView();
    if (null == imageView || null == d) {
        return;
    }

    //?ImageViewdrawable
    final float viewWidth = getImageViewWidth(imageView);
    final float viewHeight = getImageViewHeight(imageView);
    final int drawableWidth = d.getIntrinsicWidth();
    final int drawableHeight = d.getIntrinsicHeight();

    mBaseMatrix.reset();

    final float widthScale = viewWidth / drawableWidth;
    final float heightScale = viewHeight / drawableHeight;

    if (mScaleType == ScaleType.CENTER) {
        mBaseMatrix.postTranslate((viewWidth - drawableWidth) / 2F, (viewHeight - drawableHeight) / 2F);

    } else if (mScaleType == ScaleType.CENTER_CROP) {
        float scale = Math.max(widthScale, heightScale);
        mBaseMatrix.postScale(scale, scale);
        mBaseMatrix.postTranslate((viewWidth - drawableWidth * scale) / 2F,
                (viewHeight - drawableHeight * scale) / 2F);

    } else if (mScaleType == ScaleType.CENTER_INSIDE) {
        float scale = Math.min(1.0f, Math.min(widthScale, heightScale));
        mBaseMatrix.postScale(scale, scale);
        mBaseMatrix.postTranslate((viewWidth - drawableWidth * scale) / 2F,
                (viewHeight - drawableHeight * scale) / 2F);

    } else {
        RectF mTempSrc = new RectF(0, 0, drawableWidth, drawableHeight);
        RectF mTempDst = new RectF(0, 0, viewWidth, viewHeight);

        if ((int) mBaseRotation % 180 != 0) {
            mTempSrc = new RectF(0, 0, drawableHeight, drawableWidth);
        }

        switch (mScaleType) {

        case FIT_CENTER:
            //scaleType

            final float mutiple = (float) PhotoViewHelper.screenWidth(imageView.getContext())
                    / ((float) drawableWidth);

            mBaseMatrix.setScale(mutiple, mutiple, 0, 0);

            //                    mBaseMatrix
            //                            .setRectToRect(mTempSrc, mTempDst, ScaleToFit.CENTER);

            break;

        case FIT_START:
            mBaseMatrix.setRectToRect(mTempSrc, mTempDst, ScaleToFit.START);
            break;

        case FIT_END:
            mBaseMatrix.setRectToRect(mTempSrc, mTempDst, ScaleToFit.END);
            break;

        case FIT_XY:
            mBaseMatrix.setRectToRect(mTempSrc, mTempDst, ScaleToFit.FILL);
            break;

        default:
            break;
        }
    }

    resetMatrix();
}

From source file:com.coodesoft.notee.MyImageGetter.java

@Override
public Drawable getDrawable(String source) {
    Drawable d = null;

    String strSrcLeft5 = source.substring(0, 5);

    // data//from www.  jav  a 2s .c om
    if (strSrcLeft5.equalsIgnoreCase("data:")) {
        InputStream is = new ByteArrayInputStream(source.getBytes());

        //d = Drawable.createFromStream(is, null);
        //d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());

        //Bitmap dBitmap = BitmapFactory.decodeByteArray(data, 0, length);
        int nPosComma = source.indexOf(',');
        if (nPosComma > 0) {
            byte[] arrBuffer = Base64.decode(source.substring(nPosComma + 1), Base64.DEFAULT);
            //byte[] arrBuffer = Base64Coder.decode(source.substring(nPosComma + 1));
            Bitmap dBitmap = BitmapFactory.decodeByteArray(arrBuffer, 0, arrBuffer.length);
            d = new BitmapDrawable(dBitmap);
            d.setBounds(0, 0, dBitmap.getWidth(), dBitmap.getHeight());
        }

    } else {
        // url

        try {

            InputStream is = (InputStream) new URL(source).getContent();
            Bitmap dBitmap = BitmapFactory.decodeStream(is);
            if (dBitmap == null) {
                d = Resources.getSystem().getDrawable(android.R.drawable.picture_frame);
            } else {
                d = new BitmapDrawable(dBitmap);
                d.setBounds(0, 0, dBitmap.getWidth(), dBitmap.getHeight());
            }

            d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());

        } catch (MalformedURLException e) {

            e.printStackTrace();

        } catch (IOException e) {

            e.printStackTrace();

        }

        /*
         URLDrawable urlDrawable = new URLDrawable();
                
         // get the actual source
         ImageGetterAsyncTask asyncTask = 
        new ImageGetterAsyncTask( urlDrawable);
                
         asyncTask.execute(source);
                
         // return reference to URLDrawable where I will change with actual image from
         // the src tag
         return urlDrawable;
         */

    }

    return d;
}

From source file:com.example.george.sharedelementimplementation.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_animations);

    mGridView = (MyGridView) findViewById(R.id.gv_photo_grid);
    PhotoGridAdapter mAdapter = new PhotoGridAdapter(this);
    pictures = mBitmapUtils.loadPhotos(getResources());
    mAdapter.updateData(pictures);//from   www  .ja v  a 2  s.co m
    mGridView.setAdapter(mAdapter);

    // the image for pop up animation effect
    mImage = (ClippingImageView) findViewById(R.id.iv_animation);
    mImage.setVisibility(View.GONE);

    // set the background color in the fullscreen
    mTopLevelLayout = (RelativeLayout) findViewById(R.id.rl_fullscreen_bg);
    mBackground = new ColorDrawable(Color.BLACK);
    mBackground.setAlpha(0);
    mTopLevelLayout.setBackground(mBackground);

    mPager = (ClickableViewPager) findViewById(R.id.pager);
    mPager.setVisibility(View.GONE);

    // enable/disable touch event
    mGridView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (mIsInFullscreen) {
                // returning true means that this event has been consumed
                // in fullscreen the grid view is not responding any finger interaction
                return true;
            }
            return false;
        }
    });

    mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            mIsInFullscreen = true;
            // set the animating image to the clicked item
            Drawable drawable = ((ImageView) view).getDrawable();
            mImage.setImageDrawable(drawable);
            mImage.setVisibility(View.VISIBLE);

            // reset image translation
            mImage.setTranslationX(0);
            mImage.setTranslationY(0);

            // reset pager's adapter every time a view in Grid view is clicked
            mPager.setAdapter(new PhotoViewAdapter(MainActivity.this, pictures));
            mPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
                @Override
                public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

                }

                @Override
                public void onPageSelected(int position) {
                }

                @Override
                public void onPageScrollStateChanged(int state) {
                    // the GirdView should follow the Pager
                    mGridView.smoothScrollToPosition(mPager.getCurrentItem());
                }
            });
            mPager.setCurrentItem(position, false);

            final float drawableWidth = drawable.getIntrinsicWidth();
            final float drawableHeight = drawable.getIntrinsicHeight();
            // calculate the clicked view's location and width/height
            final float heightWidthRatio = drawableHeight / drawableWidth;
            final int thumbnailWidth = view.getWidth();
            final int thumbnailHeight = view.getHeight();

            int[] viewLocation = new int[2];
            int[] gridViewLocation = new int[2];
            view.getLocationOnScreen(viewLocation);
            mGridView.getLocationOnScreen(gridViewLocation);
            final int thumbnailX = viewLocation[0] + thumbnailWidth / 2;
            final int thumbnailY = viewLocation[1] + thumbnailHeight / 2;
            final int fullscreenX = gridViewLocation[0] + mGridView.getWidth() / 2;
            final int fullscreenY = gridViewLocation[1] + mGridView.getHeight() / 2;

            Log.d(TAG, "viewLocation=" + viewLocation[0] + ", " + viewLocation[1] + "\ngridViewLocation="
                    + gridViewLocation[0] + ", " + gridViewLocation[1]);
            Log.d(TAG, "thumbnailX=" + thumbnailX + ", thumbnailY=" + thumbnailY + "\nfullscreenX="
                    + fullscreenX + ", fullscreenY=" + fullscreenY);

            // for image transform, we need 3 arguments to transform properly:
            // deltaX and deltaY - the translation of the image
            // scale value - the resize value
            // clip ratio - the reveal part of the image

            // figure out where the thumbnail and full size versions are, relative
            // to the screen and each other
            mXDelta = thumbnailX - fullscreenX;
            mYDelta = thumbnailY - fullscreenY;

            // Scale factors to make the large version the same size as the thumbnail
            if (heightWidthRatio < 1) {
                mImageScale = (float) thumbnailHeight / mImage.getLayoutParams().height;
            } else {
                mImageScale = (float) thumbnailWidth / mImage.getLayoutParams().width;
            }

            // clip ratio
            if (heightWidthRatio < 1) {
                // if the original picture is in landscape
                clipRatio = 1 - heightWidthRatio;
            } else {
                // if the original picture is in portrait
                clipRatio = 1 - 1 / heightWidthRatio;
            }

            Log.d(TAG, "*************************Enter Animation*************************");
            Log.d(TAG, "(mXDelta, mTopDelta)=(" + mXDelta + ", " + mYDelta + ")\nmImageScale=" + mImageScale
                    + "\nclipRatio=" + clipRatio);

            runEnterAnimation();
        }
    });
}

From source file:com.cssweb.android.quote.QHSCGridActivity.java

private void AddViewItem(int paramInt1, LinearLayout paramLinearLayout, int paramInt2, int paramInt3,
        int paramInt4, boolean paramBoolean) {
    TextView localTextView = new TextView(this);
    float f = this.mFontSize;
    localTextView.setTextSize(f);/* ww w. ja v  a2s  .co m*/

    localTextView.setGravity(Gravity.CENTER);
    localTextView.setFocusable(paramBoolean);
    localTextView.setOnClickListener(mClickListener);
    localTextView.setOnLongClickListener(mLongClickListener);
    localTextView.setOnTouchListener(this); // touch
    localTextView.setTag(paramInt2);
    localTextView.setEnabled(paramBoolean);
    localTextView.setSingleLine(true);
    Resources localResources = getResources();
    Drawable localDrawable = null;
    if (paramInt4 == 0 && paramInt3 >= 0) {// 
        int i1 = this.residTitleCol;
        int i8 = 0;
        localTextView.setTextColor(paramInt1);
        if (paramInt3 == 0) {
            localDrawable = localResources.getDrawable(i1);
            i8 = localDrawable.getIntrinsicWidth();
        } else if (paramInt3 == 100) {
            localDrawable = localResources.getDrawable(this.residTitleScrollCol[2]);
            i8 = localDrawable.getIntrinsicWidth();
            i8 += 20;
        } else if (paramInt3 == 13) {
            localDrawable = localResources.getDrawable(this.residTitleScrollCol[0]);
            i8 = localDrawable.getIntrinsicWidth();

        } else if (paramInt3 % 2 == 0) {
            localDrawable = localResources.getDrawable(this.residTitleScrollCol[1]);
            i8 = localDrawable.getIntrinsicWidth();
        } else {
            localDrawable = localResources.getDrawable(this.residTitleScrollCol[0]);
            i8 = localDrawable.getIntrinsicWidth();
        }
        localTextView.setBackgroundDrawable(localDrawable);
        int i6 = localDrawable.getIntrinsicHeight();
        localTextView.setHeight(i6 + CssSystem.getTableTitleHeight(this));
        localTextView.setWidth(i8);
        paramLinearLayout.addView(localTextView);
        return;
    }
    if (paramInt4 != 0 && paramInt3 >= 0) {
        int i8 = 0;
        localTextView.setTextColor(paramInt1);
        if (paramInt3 == 0) {
            localDrawable = localResources.getDrawable(this.residCol);
            i8 = localDrawable.getIntrinsicWidth();
        } else if (paramInt3 == 100) {
            localDrawable = localResources.getDrawable(this.residScrollCol[2]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
            i8 += 20;
        } else if (paramInt3 == 13) {
            localDrawable = localResources.getDrawable(this.residScrollCol[0]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();

        } else if (paramInt3 % 2 == 0) {
            localDrawable = localResources.getDrawable(this.residScrollCol[1]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
        } else {
            localDrawable = localResources.getDrawable(this.residScrollCol[0]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
        }
        localTextView.setBackgroundDrawable(localDrawable);
        int i6 = localDrawable.getIntrinsicHeight();
        localTextView.setHeight(i6 + rowHeight);
        localTextView.setWidth(i8);
        paramLinearLayout.addView(localTextView);
        return;
    }
}

From source file:com.hippo.ehviewer.ui.scene.GalleryDetailScene.java

private void setActionDrawable(TextView text, Drawable drawable) {
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    text.setCompoundDrawables(null, drawable, null, null);
}

From source file:com.findcab.activity.LocationOverlay.java

private void displapDriversForAnswer(Drivers info) {

    Drawable marker = getResources().getDrawable(R.drawable.cear);
    marker.setBounds(0, 0, marker.getIntrinsicWidth(), marker.getIntrinsicHeight());
    mGeoList.clear();//  w  w  w  .  j  av a2  s.  c  o m

    OverlayItem item1 = new OverlayItem(new GeoPoint((int) (lat * 1e6), (int) (lng * 1e6)), "", "");

    Drawable maker1 = getResources().getDrawable(R.drawable.person);
    item1.setMarker(maker1);
    mGeoList.add(item1);

    int size = driversList.size();
    OverlayItem item = null;
    double driverLat, driverLng;
    DriversInfo drivers;
    Drawable maker = getResources().getDrawable(R.drawable.cear);

    driverLat = Double.parseDouble(info.getLat());
    driverLng = Double.parseDouble(info.getLng());
    item = new OverlayItem(new GeoPoint((int) (driverLat * 1e6), (int) (driverLng * 1e6)), info.getName(), " ");
    item.setMarker(maker);
    mGeoList.add(item);

    for (int i = 0; i < mGeoList.size(); i++) {
        System.out.println("?mGeoList---------->" + mGeoList.get(i).getTitle());
    }

    MyItemizedOverlay overlay = new MyItemizedOverlay(context, maker, mGeoList, info);

    mMapView.getOverlays().clear();// ??mGeoList
    mMapView.getOverlays().add(0, overlay);
    mMapView.refresh();

}

From source file:com.saulcintero.moveon.fragments.Summary1.java

private void addMarker(int overlayType, GeoPoint gp, int typeOfMarker, String title, String description) {
    Drawable marker = null;

    MarkerTypes whichMarker = MarkerTypes.values()[typeOfMarker];
    switch (whichMarker) {
    case START_MARKER:
        marker = res.getDrawable(R.drawable.start_pin);
        break;//from w  ww. ja v a2s  .c om
    case PAUSE1_MARKER:
        marker = res.getDrawable(R.drawable.pause1_pin);
        break;
    case PAUSE2_MARKER:
        marker = res.getDrawable(R.drawable.pause2_pin);
        break;
    case STOP_MARKER:
        marker = res.getDrawable(R.drawable.stop_pin);
        break;
    case PHOTO_MARKER:
        marker = res.getDrawable(R.drawable.picture_pin);
        break;
    case DISTANCE_MARKER:
        BitmapDrawable bmd = FunctionUtils.createMarkerIcon(mContext, R.drawable.distance_pin,
                String.valueOf(lap));
        marker = bmd;
        break;
    }

    int markerWidth = marker.getIntrinsicWidth();
    int markerHeight = marker.getIntrinsicHeight();
    marker.setBounds(0, markerHeight, markerWidth, 0);

    switch (overlayType) {
    case 1:
        ResourceProxy resourceProxy = new DefaultResourceProxyImpl(mContext);

        myItemizedOverlay = new MyItemizedOverlay(marker, resourceProxy);
        mapView.getOverlays().add(myItemizedOverlay);

        myItemizedOverlay.addItem(gp, "", "");
        break;
    case 2:
        ArrayList<OverlayItem> list = new ArrayList<OverlayItem>();
        MyItemizedOverlayGestureListenerTxt txtGestureOverlay = new MyItemizedOverlayGestureListenerTxt(act,
                list);
        OverlayItem overlayItem = new OverlayItem(title, description, gp);
        overlayItem.setMarkerHotspot(OverlayItem.HotspotPlace.BOTTOM_CENTER);
        overlayItem.setMarker(marker);
        txtGestureOverlay.addItem(overlayItem);
        mapView.getOverlays().add(txtGestureOverlay);
        mapView.invalidate();
        break;
    case 3:
        ArrayList<OverlayItem> list2 = new ArrayList<OverlayItem>();
        MyItemizedOverlayGestureListenerImg imgGestureOverlay = new MyItemizedOverlayGestureListenerImg(act,
                list2);
        OverlayItem overlayItem2 = new OverlayItem(title, description, gp);
        overlayItem2.setMarkerHotspot(OverlayItem.HotspotPlace.BOTTOM_CENTER);
        overlayItem2.setMarker(marker);
        imgGestureOverlay.addItem(overlayItem2);
        mapView.getOverlays().add(imgGestureOverlay);

        oItem.add(overlayItem2);

        mapView.invalidate();
        break;
    }
}