优化:WebViewActivity.java 兼容三按键导航栏
This commit is contained in:
parent
9ead9a6fb8
commit
29ddc68870
@ -73,7 +73,7 @@ public class WebViewActivity extends AbsActivity {
|
||||
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
params.topMargin = DpUtil.dp2px(1);
|
||||
// mWebView.setLayoutParams(params);
|
||||
// mWebView.setLayoutParams(params);
|
||||
//mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER);
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
@ -96,9 +96,11 @@ public class WebViewActivity extends AbsActivity {
|
||||
if (url.contains("for")) {
|
||||
mWebView.loadUrl("javascript:goAnchorTab()");
|
||||
}
|
||||
//屏幕高度-ft_title的paddingTop
|
||||
int height = DeviceUtils.getScreenHeight(mContext)-DpUtil.dp2px(24);
|
||||
view.loadUrl("javascript:window.androidObject.setHeight("+height+",0,false)");
|
||||
//真实屏幕高度-(ft_title的高度+导航栏高度)
|
||||
int height = DeviceUtils.getScreenRealHeight(mContext) - DpUtil.dp2px(72) - getCurrentNavigationBarHeight(mContext);
|
||||
if (!navigationGestureEnabled(mContext)) {
|
||||
view.loadUrl("javascript:window.androidObject.setHeight(" + height + ",0,false)");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -5,8 +5,10 @@ import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Point;
|
||||
import android.text.format.Formatter;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.WindowManager;
|
||||
|
||||
/**
|
||||
* 设备通用类
|
||||
@ -36,6 +38,19 @@ public class DeviceUtils {
|
||||
return displayMetrics.heightPixels;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取屏幕真实高度
|
||||
*
|
||||
* @param activity activity
|
||||
* @return 屏幕高度
|
||||
*/
|
||||
public static int getScreenRealHeight(Activity activity) {
|
||||
WindowManager service = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE);
|
||||
Point point = new Point();
|
||||
service.getDefaultDisplay().getRealSize(point);
|
||||
return point.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
|
||||
*
|
||||
@ -63,7 +78,7 @@ public class DeviceUtils {
|
||||
public static String getVersionName(Context context) {
|
||||
try {
|
||||
PackageManager manager = context.getPackageManager();
|
||||
PackageInfo info = manager.getPackageInfo(context.getPackageName(),0);
|
||||
PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
|
||||
return info.versionName;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -81,6 +96,7 @@ public class DeviceUtils {
|
||||
am.getMemoryInfo(mi);
|
||||
return mi.lowMemory;
|
||||
}
|
||||
|
||||
public static String getMemory(Context context) {
|
||||
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
|
||||
|
Loading…
Reference in New Issue
Block a user