如何告知搜索建议视图以缩略图形式显示的图像的 DPI?
我有一个使用 Android 搜索和自动搜索建议功能的活动。
我在活动中使用的缩略图都存储在 SD 卡上(有很多)并且都是 MDPI 分辨率。
当在我的活动中使用它们时,这很好,因为我可以考虑这一点并适当缩放,但是在搜索建议视图中,缩略图似乎被假定为当前 DPI,因此缩略图在 HDPI 设备上看起来很小。
我正在使用自定义 ContentProvider
检索搜索建议视图的缩略图并覆盖 openFile
方法 - 但是我看不到这如何让我对设置 DPI 进行任何控制因为它只返回一个通用的 ParcelFileDescriptor
。
是否可以使用 ParcelFileDescriptor
来通知 DPI 的搜索建议视图?或者还有其他可行的方法吗? 我自己无法直接控制它,因为 Android 框架处理数据到自动建议视图的映射。
我的 openFile 方法如下所示:
public ParcelFileDescriptor openFile( Uri uri, String mode ) {
String deletePackage = "content://" + PACKAGE_NAME + "/";
String url = uri.toString();
String filePath = url.substring(deletePackage.length());
Log.d("AssetsContentProvider", "openFile: " + filePath);
File file = new File( filePath );
ParcelFileDescriptor parcel = null;
try {
parcel = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
} catch (FileNotFoundException e) {
Log.e( "AssetsContentProvider", "Error finding: " + file.getPath() + "\n" + e.toString() );
}
return parcel;
}
这似乎是我在自动建议管理器请求文件和显示文件之间可以控制文件的唯一地方。
I have an activity which uses the Android search and the auto search-suggestions capability.
The thumbnails I am using in my activity are all stored on the SD card (there's a lot of them) and are all in MDPI resolution.
When using them in my activity this is fine as I can account for this and scale appropriately, however in the search suggestions view it seems the thumbnail is assumed to be at the current DPI, and thus the thumbnails look small on HDPI devices.
I am retrieving the thumbnails for the search suggestions view using a custom ContentProvider
and overriding the openFile
method - however I can't see how this gives me any control over setting the DPI as it just returns a generic ParcelFileDescriptor
.
Is it possible to use the ParcelFileDescriptor
to inform the search suggestions view of the DPI? Or is there another possible method?
I cannot control it directly myself as the Android framework handles the mapping of data to the auto-suggestions view.
My openFile
method looks like:
public ParcelFileDescriptor openFile( Uri uri, String mode ) {
String deletePackage = "content://" + PACKAGE_NAME + "/";
String url = uri.toString();
String filePath = url.substring(deletePackage.length());
Log.d("AssetsContentProvider", "openFile: " + filePath);
File file = new File( filePath );
ParcelFileDescriptor parcel = null;
try {
parcel = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
} catch (FileNotFoundException e) {
Log.e( "AssetsContentProvider", "Error finding: " + file.getPath() + "\n" + e.toString() );
}
return parcel;
}
This seems to be the only place I have any control over the file between the auto-suggest manager requesting it and it being displayed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论