真正需要帮助搞清楚为什么一个位图放置在一个不正确的image_view [英] Really need help figuring out why a bitmap is placed on an an image_view incorrectly

查看:150
本文介绍了真正需要帮助搞清楚为什么一个位图放置在一个不正确的image_view的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题已经困扰我好几天了,我想不通为什么地球上正在发生。我有检测用于一个面的方法,如果检测到面部,该方法将绘制一个矩形沿面在画布上。

这部分工作正常。

的问题是,当它显示在我的XML文件中的image_view,将显示在图像视图的最左边中间,在一个盒子里,而不是在与宽度FILL_PARENT中心

我想到了一个可能的解决方法的:设置位图作为bitmapdrawable,但只帆布画位图,这样我就可以得到bitmapdrawable在中间,但周围没有红色框

我评论了我的位图绘制的测试,并把它作为我现在......只显示我的XML中最左边的image_view的。请看一看和帮助!

我贴到引擎收录,因为code是长了一点(我也是用视图鳍内的线性布局)。

方法:

http://pastebin.com/KQ5Pmx45

XML:

http://pastebin.com/jbt3j40h

既然我能够得到的面孔来检测,我可以一个位图绘制粘贴到ImageButton的,它中心就好了,有没有办法让周围的bitmapdrawable矩形,如果我的问题不能得到解决?

谢谢!

编辑:我试图执行它变成一个RelativeLayout的,仍然做着同样的事情:

http://pastebin.com/daqMdXjB

 难道这code是让我为中心的方法是什么?    公共无效processCameraImage(意向意图){
        mFlipper.setDisplayedChild(1); // 1 ==你的第二个布局
        mThePicture =(ImageView的)findViewById(R.id.image_view); //
        。cameraBitmap =(位图)intent.getExtras()获得(数据);        mThePicture.setImageBitmap(cameraBitmap);
        detectFaces();    }


解决方案

在ImageView的标签使用的android:scaleType =fitCenter或Android:scaleType =centerInside或Android:scaleType =中心<一个href=\"http://developer.android.com/intl/de/reference/android/widget/ImageView.html#attr_android%3ascaleType\"相对=nofollow> sclaetype ATTR DOC

我希望,我明白你的问题的权利。

this problem has been bothering me for days and I cannot figure out why on earth it is happening. I have a method that detects for a face, if a face is detected, the method will draw a rectangle on a canvas along the face.

That part works fine.

The problem is, when it displays to the image_view in my xml file, it will display on the far left middle of the image view, in a box, rather than in the center with the width as fill_parent.

I thought of a possible workaround : to set the bitmap as a bitmapdrawable, but canvas only draws to bitmaps, so I can get the bitmapdrawable in the middle, but with no red box around it.

I commented out my testing of bitmap drawable, and left it as what I have now...it only displays to my xml in the far left of the image_view. Please take a look and help!

I posted to pastebin because the code is a bit long (I am also using a linear layout within a view flipper).

method:

http://pastebin.com/KQ5Pmx45

xml:

http://pastebin.com/jbt3j40h

Since I am able to get the faces to detect, and I can paste a bitmap drawable to an imagebutton and it centers just fine, is there a way to get the rectangle around the bitmapdrawable if my problem cannot be solved?

Thanks!

EDIT: I tried to implement it into a RelativeLayout and still doing the same thing:

http://pastebin.com/daqMdXjB

Could this code be getting my way of centering?

    public void processCameraImage(Intent intent) {
        mFlipper.setDisplayedChild(1); // 1 == your second layout
        mThePicture = (ImageView) findViewById(R.id.image_view); //
        cameraBitmap = (Bitmap) intent.getExtras().get("data");

        mThePicture.setImageBitmap(cameraBitmap);
        detectFaces();

    }

解决方案

Use on Imageview tag android:scaleType="fitCenter" or android:scaleType="centerInside" or android:scaleType="center" sclaetype attr doc

I hope, I understood your problem right.

这篇关于真正需要帮助搞清楚为什么一个位图放置在一个不正确的image_view的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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