我正在尝试在 Android 应用程序中阅读 pdf 文件。
触发以下意图以获取 URI。
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("application/pdf");
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
startActivityForResult(intent, PDF_FILE_SELECTOR_INTENT_ID);
Run Code Online (Sandbox Code Playgroud)
问题是,该Downloads
文件夹还显示我已删除的旧文件。另外,当我选择这些文件时,URI
会在onActivityResult()
. 当我创建File
并URI
检查它时exists()
,它会返回false
,这是有道理的,因为我已经从Downloads
文件夹中删除了该文件。
如何确保Downloads
显示的文件夹ACTION_GET_CONTENT
仅显示当前存在且未删除的文件?
谢谢。
我在纹理视图中重复播放视频,其目的是显示背景视频。我需要将纹理视图的宽度和高度设置为 match_parent。
我想缩放视频,使其看起来在播放它的纹理视图上被裁剪。
我按照这个链接TextureView缩放并使用了给定的函数。
private void updateTextureViewSize(int viewWidth, int viewHeight) {
float scaleX = 1.0f;
float scaleY = 1.0f;
if (mVideoWidth > viewWidth && mVideoHeight > viewHeight) {
scaleX = mVideoWidth / viewWidth;
scaleY = mVideoHeight / viewHeight;
} else if (mVideoWidth < viewWidth && mVideoHeight < viewHeight) {
scaleY = viewWidth / mVideoWidth;
scaleX = viewHeight / mVideoHeight;
} else if (viewWidth > mVideoWidth) {
scaleY = (viewWidth / mVideoWidth) / (viewHeight / mVideoHeight);
} else if …
Run Code Online (Sandbox Code Playgroud) Loaders
已被弃用 forViewModel
和LiveData
并且 Android 现在有一个Paging Library
for 分页。
大多数网络示例都解释了从网络端点获取图像。
我想在我的应用程序中创建一个图像库,并想使用Jetpack
提到的组件/框架,但似乎找不到CursorLoader
.
我是否应该在实例CursorLoader
内部使用PageKeyedDataSource
该实例,该实例将被使用,而该实例又将被forPagedList
使用?PagedListAdapter
RecyclerView
我需要删除应用程序中所有按钮的圆角并使用平坦的背景。最好是一种颜色。
这是我的风格:
<style name="Component.MyTheme.Button" parent="Widget.MaterialComponents.Button.TextButton">
<item name="android:textColor">@color/white_50</item>
<item name="backgroundTint">@color/black</item>
<item name="cornerRadius">@null</item>
</style>
Run Code Online (Sandbox Code Playgroud)
这就是我将其应用到我的主题中的方式。
<item name="materialButtonStyle">@style/Component.MyTheme.Button</item>
Run Code Online (Sandbox Code Playgroud)
我想改变这个
对此
编辑:忽略第二张图像两端的白条。
android android-button material-design material-components-android
我正在使用 recyclerview,我必须在 recyclerview 中选择最后一项。
我首先滚动到 recyclerview,然后对所选项目调用 performClick() 方法。
这是代码。
int latestPostIndex = reactionsListAdapter.getItemCount() - 1;
rvReactionsList.scrollToPosition(latestPostIndex);
rvReactionsList.getChildAt(latestPostIndex).performClick();
Run Code Online (Sandbox Code Playgroud)
latestPostIndex 已正确填充。问题是在滚动完成之前调用 performClick,因此应用程序崩溃。
如何让 performClick() 等到 scrollToPosition() 完成?