我在對話框中加載webview,但它不水平滾動。以下是我的代碼。Webview不在對話框中水平滾動
@Override
protected void onCreate(Bundle arg0) {
// TODO Auto-generated method stub
super.onCreate(arg0);
TwitterDialog fb = new TwitterDialog(this);
fb.abc();
}
class TwitterDialog extends Dialog {
Context context;
String url = "https://www.facebook.com";
public TwitterDialog(Context context) {
super(context);
this.context = context;
}
void abc() {
LinearLayout mContent = new LinearLayout(context);
mContent.setOrientation(LinearLayout.VERTICAL);
final float scale = context.getResources().getDisplayMetrics().density;
float[] dimensions = new float[] { 400.0f, 500.0f };
addContentView(mContent, new FrameLayout.LayoutParams(
(int) (dimensions[0] * scale + 0.5f), (int) (dimensions[1]
* scale + 0.5f)));
FrameLayout.LayoutParams FILL = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT);
ScrollView _scroll = new ScrollView(MyMainActivity.this);
_scroll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
WebView mWebView = new WebView(context);
mWebView.setWebViewClient(new WebClicent());
mWebView.setScrollbarFadingEnabled(false);
mWebView.setHorizontalScrollBarEnabled(true);
mWebView.setWebViewClient(new MyWebViewClient());
mWebView.getSettings().setUseWideViewPort(true);
mWebView.loadUrl(url);
mWebView.setLayoutParams(FILL);
// _scroll.addView(mWebView);
mContent.addView(mWebView);
TwitterDialog.this.show();
}
}
private class MyWebViewClient extends WebViewClient {
@Override
// show the web page in webview but not in web browser
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
我得到以下輸出。但它不是水平滾動的。
http://stackoverflow.com/questions/19929047/twitter-authorization-webview-scrollbar-not-working-in-android – Scorpion 2013-11-12 13:02:03
@Scorpion您的鏈接無法正常工作。 – 2013-11-12 13:14:54