War*_*ith 0 android webview invalidation fill-parent android-framelayout
我有一个带有对话框主题的Activity.
<activity
android:name=".MyActivity"
android:theme="@android:style/Theme.Dialog" />
Run Code Online (Sandbox Code Playgroud)
该Activity使用以下xml布局:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_article_frame_layout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000">
<WebView
android:id="@+id/activity_article_web_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<Button
android:id="@+id/activity_article_close_button"
android:layout_width="25dip"
android:layout_height="26dip"
android:layout_marginTop="5dip"
android:layout_marginRight="5dip"
android:layout_gravity="right|top"
android:background="@drawable/close_button" />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
WebView的内容将从SD卡上的存储文件加载(作为意图数据提供的内容).这发生在onCreate()中:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_article);
// Handle to the WebView
mWebView = (WebView) findViewById(R.id.activity_article_web_view);
initWebView();
mWebView.loadDataWithBaseURL(null, myHtmlContent, "text/html", "utf-8", null);
// Handle to the close button
mCloseButton = (Button) findViewById(R.id.activity_article_close_button);
mCloseButton.setOnClickListener(this);
}
Run Code Online (Sandbox Code Playgroud)
项目详情:minSDK:7(2.1)
我的问题是,WebView和/或FrameLayout没有fill_parent.活动的高度与按钮的高度完全相同.我几乎无法阅读我页面的第一行.我的问题只发生在蜂窝3.x上.在下面(<= 2.3),活动填充了父母,我看到了完整的网站.
我试图动态创建WebView.我试图在onCreate()中设置LayoutParams.没有改变.我也尝试在FrameLayout和WebView上调用invalidate(),但结果是一样的......
小智 7
这个解决方案对我有用:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_layout);
getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3448 次 |
| 最近记录: |