gpt4 book ai didi

android - 在android中将图像大小设置为全屏

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:19:02 24 4
gpt4 key购买 nike

我有一个安卓应用程序,我在其中使用安卓相机拍照。这张照片是在 activity A 中拍摄的,然后发送到 activity B 进行编辑。

这就是我在 activity B 中接收图像的方式:

Bundle extras = getIntent().getExtras();
BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = 5;
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);
ImageView imageView = (ImageView) findViewById(R.id.myPic);
imageView.setImageBitmap(bitmapResult);

如您所见,我正在旋转我收到的 90 度的 位图:

Matrix mat=new Matrix();
mat.postRotate(90);

这是我在 xml 文件中的 imageView:

<ImageView  
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:id="@+id/myPic"
/>

我面临的问题是我的图片不是全屏...它几乎是全屏但不是全屏。正如您在这里看到的:

enter image description here

如果你能帮我增加一点它的尺寸,我真的很感激。谢谢

编辑:我只想增加图像的宽度。抱歉!!

最佳答案

您可以使用 ImageView.ScaleType

ImageView.ScaleType="CENTER_CROP"

关于android - 在android中将图像大小设置为全屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6912006/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com