我有一个Activity在其中下载图像的zip文件然后解压缩getFilesDir().路径是这样的:
/data/user/0/packagename/files/files/example.png
但是,当我尝试加载这些图像时,它们没有显示.我正在使用此代码获取路径并加载图像:
String loc = getFilesDir().getPath() + "/" + Config.IMAGES_LOCATION +"/";
String imageloc = loc + model.getThumbnail();
Glide.with(ActivityImageGallery.this).load(imageloc).into(image);
Run Code Online (Sandbox Code Playgroud)
imageloc路径与保存位置相同,并且从路径创建文件时,它显示它将存在.
我尝试file://在路径前使用,但这也不起作用.WRITE_EXTERNALen READ_EXTERNAL权限被询问并被授予.
我无法让我的 ViewPager 页面尊重状态栏高度。我的 ViewPager 有几个页面,在其中一个页面上有一张需要在半透明状态栏下显示的图像。其余页面只需要一个彩色状态栏,所以我的想法是在片段布局上使用 fitsSystemWindows="true" ,作为 viewpager 的页面。但这行不通。似乎在第一次绘制时只有第二页应用了填充。但是当滚动页面时。它消失了。所以在我看来,页面没有从 ViewPager 得到调度来应用插图。但我不知道如何实现它。
我试图用 做一些事情
public static void setOnApplyWindowInsetsListener(View v, OnApplyWindowInsetsListener listener),但我无法开始工作。我的想法是以某种方式在每个新页面上应用插图。也许这是正确的方法,但我找不到调用此方法的正确位置。
那么有没有人可以帮助我解决这个问题?我将在下面放置我的一些代码以提供有关该问题的一些上下文。
活动.xml
<..WindowInsetsFrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Run Code Online (Sandbox Code Playgroud)
这是一个自定义布局管理器,用于支持更改片段(片段转换)并再次应用 windowInset。仅供参考,这是代码:
public class WindowInsetsFrameLayout extends FrameLayout {
public WindowInsetsFrameLayout(@NonNull Context context) {
this(context, null);
}
public WindowInsetsFrameLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public WindowInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
// Look for replaced fragments and apply the insets again.
setOnHierarchyChangeListener(new OnHierarchyChangeListener() {
@Override …Run Code Online (Sandbox Code Playgroud) 我试图显示一张地图,为地图上的几个区域设置动画百分比.但是javascript(在浏览器中有效)根本不显示任何动画或百分比.webmpa.generateJs()生成javascript以设置百分比的动画,函数initialize用于绘制地图.
WebSettings settings = webView.getSettings();
settings.setAppCacheEnabled(true);
settings.setDomStorageEnabled(true);
settings.setDatabaseEnabled(true);
settings.setJavaScriptEnabled(true);
final WebMap webMap = new WebMap();
webView.addJavascriptInterface(webMap.getInterface(getActivity().getApplication(),this), "Android");
webView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
Log.d(TAG,webMap.generateJs());
webView.loadUrl("javascript:" + webMap.generateJs());
webView.loadUrl("javascript:initialize();");
}
});
webView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
webView.setBackgroundColor(Color.TRANSPARENT);
webView.loadUrl(MAP_URL);
Run Code Online (Sandbox Code Playgroud)