作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试拍摄用户可以在应用程序中查看的视频的缩略图并将其显示在 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/
我有一个具有可变数量子元素的固定大小的 div。我不知道 children 的大小。目标是缩小它们以适合父级。 例子: .parent { width: 100px; height: 100p
我是一名优秀的程序员,十分优秀!