优化:WebViewActivity.java 兼容三按键导航栏
This commit is contained in:
parent
9ead9a6fb8
commit
29ddc68870
@ -96,9 +96,11 @@ public class WebViewActivity extends AbsActivity {
|
|||||||
if (url.contains("for")) {
|
if (url.contains("for")) {
|
||||||
mWebView.loadUrl("javascript:goAnchorTab()");
|
mWebView.loadUrl("javascript:goAnchorTab()");
|
||||||
}
|
}
|
||||||
//屏幕高度-ft_title的paddingTop
|
//真实屏幕高度-(ft_title的高度+导航栏高度)
|
||||||
int height = DeviceUtils.getScreenHeight(mContext)-DpUtil.dp2px(24);
|
int height = DeviceUtils.getScreenRealHeight(mContext) - DpUtil.dp2px(72) - getCurrentNavigationBarHeight(mContext);
|
||||||
|
if (!navigationGestureEnabled(mContext)) {
|
||||||
view.loadUrl("javascript:window.androidObject.setHeight(" + height + ",0,false)");
|
view.loadUrl("javascript:window.androidObject.setHeight(" + height + ",0,false)");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -5,8 +5,10 @@ import android.app.ActivityManager;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.graphics.Point;
|
||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备通用类
|
* 设备通用类
|
||||||
@ -36,6 +38,19 @@ public class DeviceUtils {
|
|||||||
return displayMetrics.heightPixels;
|
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(像素)
|
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
|
||||||
*
|
*
|
||||||
@ -81,6 +96,7 @@ public class DeviceUtils {
|
|||||||
am.getMemoryInfo(mi);
|
am.getMemoryInfo(mi);
|
||||||
return mi.lowMemory;
|
return mi.lowMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getMemory(Context context) {
|
public static String getMemory(Context context) {
|
||||||
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||||
ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
|
ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
|
||||||
|
Loading…
Reference in New Issue
Block a user