android:layout_width="match_parent"
android:layout_height="match_parent"
>
android:id="@+id/rootView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
private void measureContent(finalString message) {
LinearLayout.LayoutParams params =newLinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
finalWebView webView =newWebView(this);
mRootView.addView(webView,params);
webView.loadDataWithBaseURL(null,message,"text/html","utf-8", null);
webView.setWebViewClient(newWebViewClient() {
@Override
public voidonPageFinished(finalWebView view,String url) {
newHandler().postDelayed(newRunnable() {
public voidrun() {
Toast.makeText(MainActivity.this,webView.getMeasuredHeight()+"==="+webView.getHeight(),Toast.LENGTH_SHORT).show();
}
},200);//时间很关键
super.onPageFinished(view,url);
}
});
}