From 7cb89035d859a66b90630d104c971509f92bae7d Mon Sep 17 00:00:00 2001 From: plx_wangyi Date: Fri, 13 Sep 2024 23:10:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=BF=E5=9C=BA=E4=BD=BF=E7=94=A8=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E8=8E=B7=E5=8F=96=E7=8A=B6=E6=80=81=E6=A0=8F=E9=AB=98?= =?UTF-8?q?=E5=BA=A6=E7=BB=99=20webview?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fragment/MainHomeCommunityFragment.java | 18 ++++++++++++++++++ .../java/com/yunbao/main/utils/UIUtils.java | 14 ++++++++++++++ .../main/res/layout/view_main_encourage.xml | 1 - 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 main/src/main/java/com/yunbao/main/utils/UIUtils.java diff --git a/main/src/main/java/com/yunbao/main/fragment/MainHomeCommunityFragment.java b/main/src/main/java/com/yunbao/main/fragment/MainHomeCommunityFragment.java index a56b42658..762980571 100644 --- a/main/src/main/java/com/yunbao/main/fragment/MainHomeCommunityFragment.java +++ b/main/src/main/java/com/yunbao/main/fragment/MainHomeCommunityFragment.java @@ -8,6 +8,8 @@ import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -65,14 +67,18 @@ import com.yunbao.main.activity.MainActivity; import com.yunbao.main.activity.MyWalletActivity; import com.yunbao.main.dialog.EncourageDialog; import com.yunbao.main.utils.BottomBarUtil; +import com.yunbao.main.utils.UIUtils; import com.yunbao.share.ui.SharePopDialog; import com.yunbao.video.activity.VideoPlayActivity; import com.yunbao.video.utils.VideoStorge; +import net.lucode.hackware.magicindicator.buildins.UIUtil; + import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import java.util.Arrays; +import java.util.List; import java.util.Locale; public class MainHomeCommunityFragment extends BaseFragment { @@ -180,6 +186,18 @@ public class MainHomeCommunityFragment extends BaseFragment { view.loadUrl(jsUrl); view.reload(); } + + view.postDelayed(new Runnable(){ + @Override + public void run() { + int height = view.getMeasuredHeight(); + + int starHeight = UIUtils.getStatusBarHeight(mContext); + Log.e("网页高度", height + ""); + view.loadUrl("javascript:setTop(" + 200 + ")"); + } + },3000); + } }); mWebView.setWebChromeClient(new WebChromeClient() { diff --git a/main/src/main/java/com/yunbao/main/utils/UIUtils.java b/main/src/main/java/com/yunbao/main/utils/UIUtils.java new file mode 100644 index 000000000..24e3f237b --- /dev/null +++ b/main/src/main/java/com/yunbao/main/utils/UIUtils.java @@ -0,0 +1,14 @@ +package com.yunbao.main.utils; + +import android.content.Context; + +public class UIUtils { + public static int getStatusBarHeight(Context mContext) { + int result = 0; + int resourceId = mContext.getResources().getIdentifier("status_bar_height", "dimen", "android"); + if (resourceId > 0) { + result = mContext.getResources().getDimensionPixelSize(resourceId); + } + return result; + } +} diff --git a/main/src/main/res/layout/view_main_encourage.xml b/main/src/main/res/layout/view_main_encourage.xml index d09c5d0bb..7a7ab6015 100644 --- a/main/src/main/res/layout/view_main_encourage.xml +++ b/main/src/main/res/layout/view_main_encourage.xml @@ -4,7 +4,6 @@ android:layout_height="match_parent">