gpt4 book ai didi

android - 在imageview中显示水平和垂直图像

转载 作者:行者123 更新时间:2023-11-30 02:19:53 25 4
gpt4 key购买 nike

我在我的应用程序中从 SD 卡获取图片。我正在使用 imageview 来显示图像。但是,由于我不知道图像是水平的还是垂直的,我该如何在 imageview 中适本地显示水平或垂直图像。谢谢

 File img_file = new File(picture_path);
bm = BitmapFactory.decodeFile(img_file.getAbsolutePath());
iv2.setImageBitmap(bm);

ImageView xml

 <ImageView
android:id="@+id/iv_image2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:scaleType="fitXY"
android:adjustViewBounds="true"
/>

最佳答案

不幸的是,这是一件很复杂的事情。您可以读取 Xif 数据并确定其方向,请参阅 How to determine orientation of picture without ExifInterface?Android get Orientation of a camera Bitmap? And rotate back -90 degrees的想法。然后你可以手动旋转它。

关于android - 在imageview中显示水平和垂直图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28750508/

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