广场使用动态获取状态栏高度给 webview

This commit is contained in:
plx_wangyi 2024-09-13 23:10:29 +08:00
parent f39f2b483e
commit 7cb89035d8
3 changed files with 32 additions and 1 deletions

View File

@ -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() {

View File

@ -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;
}
}

View File

@ -4,7 +4,6 @@
android:layout_height="match_parent">
<LinearLayout
android:layout_marginTop="40dp"
android:id="@+id/rootView"
android:layout_width="match_parent"
android:layout_height="match_parent"