我对Android很新,我的情况是我在同一个Activity上获得了webview1和webview2,并按钮切换它们。 我不知道这样做 1.我滚动webview1和webview2自动滚动。 2. webview1和webview2将滚动到同一时间结束
public class MainActivity extends AppCompatActivity {
WebView myWebView,myWebView2;
int webTextDefault = 100;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myWebView = (WebView)findViewById(myWebView1);
//myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.setBackgroundColor(Color.TRANSPARENT);
myWebView.loadUrl("file:///android_asset/try1.html");
myWebView.setWebViewClient(new WebViewClient());
myWebView2 = (WebView)findViewById(R.id.myWebView2);
myWebView2.setBackgroundColor(Color.TRANSPARENT);
myWebView2.setVisibility(View.GONE);
myWebView2.loadUrl("file:///android_asset/try2.html");
myWebView2.setWebViewClient(new WebViewClient());
}
public void myClick(View v) {
switch (v.getId()){
case R.id.button:
myWebView2.setVisibility(View.GONE);
myWebView.setVisibility(View.VISIBLE);
break;
case R.id.button2:
myWebView2.setVisibility(View.VISIBLE);
myWebView.setVisibility(View.GONE);
break;
}
}
}