gpt4 book ai didi

java - ImageView 折叠并且不显示创建的缩略图

转载 作者:行者123 更新时间:2023-12-02 02:52:35 24 4
gpt4 key购买 nike

我正在尝试拍摄用户可以在应用程序中查看的视频的缩略图并将其显示在 ImageView 中。但是,当我尝试显示缩略图时,看起来整个 ImageView 消失了,根本没有图像出现。

我尝试使用不是缩略图的测试照片,它肯定显示在 ImageView 中,所以我不认为这是 XML 的问题,但也可能是。我已经用谷歌搜索了几个小时,但不明白我在哪里搞砸了。我的代码已经来自 Stack Overflow。

uri = Uri.parse("android.resource://"+ getActivity().getPackageName() +"/"+R.raw.test);
Bitmap thumb = ThumbnailUtils.createVideoThumbnail(uri.getPath(), Thumbnails.MICRO_KIND);

//Create ImageView to hold the thumbnail
ImageView imageView = view.findViewById(R.id.mediaPreview);
imageView.setImageBitmap(thumb);

XML

    <LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/startup_dialog"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="25"
tools:context=".ui.MainActivity">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/getting_started"
android:gravity="start"
android:layout_gravity="start"/>

<ImageView
android:id="@+id/mediaPreview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="10dp"
/>

最佳答案

图像本来可以显示,但没有显示,因为您可能有更大像素的图像,请尝试更改图像像素或尝试添加另一个图像。

关于java - ImageView 折叠并且不显示创建的缩略图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57098198/

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