我想在布局中添加两个webview..我使用frameLayout
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<WebView
android:id="@+id/webview1"
android:layout_width="350dip"
android:layout_height="350dip" />
<WebView
android:layout_height="250dip"
android:layout_width="250dip"
android:id="@+id/webview2"
/>
</FrameLayout>
在主要 Activity 中:
web1=(WebView)findViewById(R.id.webview1);
web2=(WebView)findViewById(R.id.webview2);
web1.loadUrl("http://www.google.com");
web2.loadUrl("http://www.youtube.com");
web2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Animation anim=AnimationUtils.loadAnimation(FrameWebViewActivity.this, android.R.anim.slide_in_left);
web2.setAnimation(anim);
}
});
但是当运行项目时,它只显示 webview youtube 全屏..我想显示两个 webview..我必须做什么??
最佳答案
使用另一个布局,a FrameLayout
用于仅显示单个子元素。
我建议使用线性布局并指定权重将 View 划分为所需的比例。
关于android - 在framelayout中添加两个webview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11380253/