分层绘制对象的集合大小? [英] Set size of Layered Drawable?

查看:73
本文介绍了分层绘制对象的集合大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提出一个图标我的应用程序。该应用程序基本上是一个朋友查找。我创建一个覆盖,看起来就像从谷歌纵横图标。我有一个,要用户改变由于图像和我有边界。我已经能够做到分层绘制和覆盖很好,但问题是,图像一直延伸到边框的大小。这是一个问题,因为,如果你从来没有见过的谷歌纬度图标,它与它的开放空间底部的一个点。

我需要做的是,在某种程度上限制了改变图像的大小,边界的方形部分的边界。任何帮助将非常AP preciated。这里是我的代码段:

  BitmapFactory.Options选项=新BitmapFactory.Options();
    options.inSampleSize = 25;
    位图位= BitmapFactory.de codeFILE(照片,选件);
    借鉴=新BitmapDrawable(位);

    资源R = getResources();
    绘制对象[]层=新绘制对象[2];
    层[0] =绘制;
    层[1] = r.getDrawable(R.drawable.border);
    LayerDrawable layerDrawable =新LayerDrawable(层);
    借鉴= layerDrawable;

    }其他{
    画= this.getResources()getDrawable(R.drawable.androidmarker)。
    }

    HelloItemizedOverlay itemizedoverlay =新HelloItemizedOverlay(画,这一点);

    的GeoPoint点=新的GeoPoint(纬度,经度);
    OverlayItem overlayitem =新OverlayItem(点,用户名,其他+:+状​​态+:在位置更新:+ update_at);
    items.add(overlayitem);
    itemizedoverlay.addOverlay(overlayitem);
    mapOverlays.add(itemizedoverlay);
 

解决方案

搞笑的是矮个子后,我贴这个,我找到了答案。我一直在寻找在错误的地方来调整图像大小。我尝试了位图,在绘制时,layerdrawable内部的层次。但是,我从来没有尝试过是layerdrawable本身。解决的办法是如下:

 资源R = getResources();
    绘制对象[]层=新绘制对象[2];
    层[0] =绘制;
    层[1] = r.getDrawable(R.drawable.border);
    LayerDrawable layerDrawable =新LayerDrawable(层);
    layerDrawable.setLayerInset(0,0,0,0,12);
    借鉴= layerDrawable;
 

的layerDrawable插页方法如下:

  layerDrawable.setLayerInset(*层的指数*,*左小图*,*顶*,*权*,*下*);
 

谢谢你们!

I am making a icon for my app.. The app is basically a friend finder. I am creating a overlay that looks much like the icons from Google Latitude. I have an image that changes due to the user and I have the boarder. I've been able to do the layered drawable and overlay fine, but the problem is, the image stretches to the size of the border. This is a problem because, if you've never seen the Google Lat icons, it has a point on the bottom with open space between it.

What I need to do is, somehow restrict the size of the changing image to the bounds of the square portion of the border. Any Help would be much appreciated. Here is my snippet:

    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inSampleSize = 25;  
    Bitmap bit = BitmapFactory.decodeFile(photo, options);
    draw = new BitmapDrawable(bit);

    Resources r = getResources();
    Drawable[] layers = new Drawable[2];
    layers[0] = draw;
    layers[1] = r.getDrawable(R.drawable.border);
    LayerDrawable layerDrawable = new LayerDrawable(layers);
    draw = layerDrawable;

    }else{
    draw = this.getResources().getDrawable(R.drawable.androidmarker);
    }

    HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(draw, this);

    GeoPoint point = new GeoPoint(lat,lon);
    OverlayItem overlayitem = new OverlayItem(point, username, avail + " : " + status + " : Position updated at : " + update_at);
    items.add(overlayitem);
    itemizedoverlay.addOverlay(overlayitem);
    mapOverlays.add(itemizedoverlay);

解决方案

Funny that shorty after I posted this, I found the answer. I was looking in all of the wrong places to resize the image. I tried the bitmap, the drawable, the layers inside of the layerdrawable. But, what I never tried was the layerdrawable itself. The solution is below:

  Resources r = getResources();
    Drawable[] layers = new Drawable[2];
    layers[0] = draw;
    layers[1] = r.getDrawable(R.drawable.border);
    LayerDrawable layerDrawable = new LayerDrawable(layers);
    layerDrawable.setLayerInset(0, 0, 0, 0, 12);
    draw = layerDrawable;

The layerDrawable inset method is as follows:

layerDrawable.setLayerInset(*index of layer*, *left inset*, *top*, *right*, *bottom*);

Thanks guys!

这篇关于分层绘制对象的集合大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆