imageview的问题

adr*_*ian 2 android imageview

我有一个Android应用程序,我使用Android相机拍照然后我查看照片,如果我喜欢它然后我上传到一个网站的图片.

将图片上传到网站我注意到有几个像素在手机上看不到!!!在网站上图片有一些额外的细节在手机屏幕上看不到!!!

电话屏幕上的图片设置在imageview中.

这是活动的布局:

<ImageView  
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:layout_gravity="center"
android:scaleType="centerCrop"
android:id="@+id/myPic"
/>
Run Code Online (Sandbox Code Playgroud)

<Button 
android:text="Confirm Photo"
android:layout_toLeftOf="@id/back"
android:id="@+id/confirm"
android:layout_marginTop="530dip"
android:layout_height="wrap_content" 
android:layout_width="165dip"
android:layout_alignParentRight="true"
>
   </Button>

 </RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

这就是我将图片设置为imageview:

Bundle extras = getIntent().getExtras();
    BitmapFactory.Options options=new BitmapFactory.Options();
    options.inSampleSize =2;
    byte[] imageData = extras.getByteArray("imageData");
    Bitmap myImage = BitmapFactory.decodeByteArray(imageData , 0, imageData.length,options);


    Matrix mat=new Matrix();
mat.postRotate(90);
bitmapResult = Bitmap.createBitmap(myImage, 0, 0,  myImage.getWidth(),myImage.getHeight(), mat, true); 

    Canvas c = new Canvas(bitmapResult);
    drawTextImage(bitmapResult);
    StoreByteImage(this, bitmapResult,100);
ImageView imageView = (ImageView) findViewById(R.id.myPic);
imageView.setImageBitmap(bitmapResult);
Run Code Online (Sandbox Code Playgroud)

对于额外的代码或其他细节,我在这里给你.谢谢

NSj*_*nas 6

如果您在谈论网站上的图片大于手机上的图片,那么这是因为您的比例类型设置为:

android:scaleType="centerCrop"
Run Code Online (Sandbox Code Playgroud)

并且您的imageview绑定可能与图像不匹配(因此图像被裁剪).尝试将此行添加到imageview,看看它是否有所作为.

android:adjustViewBounds="true"
Run Code Online (Sandbox Code Playgroud)

最后将布局高度和宽度属性更改为:

layout_width="fill_parent"
layout_height="wrap_content"
Run Code Online (Sandbox Code Playgroud)