Ari*_*ant 14 android fullscreen webview
如何使Android应用程序的webview全屏.我已经在布局xml文件中添加了webview,但它不会延伸到布局的边缘,webview的所有边都有一些类型的边距.我还添加了一个图像,让你们看到它实际上是什么样子.

我所说的是webview周围的空间,而不是通知栏或标题栏
这是布局代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".WebView" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Shake / Tilt Your Phone To Get Accelerometer Motion Alerts" />
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
Vis*_*ale 17
从上面的代码删除padding tags-
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
Run Code Online (Sandbox Code Playgroud)
它将完成这项工作,并确保删除您正在渲染到可能包含留下一些空间的那些标记的WebView的HTML边距/填充.
只需android:theme在AndroidManifest.xml文件中添加(或更改)活动属性和以下行
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
Run Code Online (Sandbox Code Playgroud)
小智 5
将 webview 放入对话框弹出窗口。
WebView webview = new WebView(this/*put your activity object*/);
webview.getSettings().setLoadWithOverviewMode(true);
webview.getSettings().setUseWideViewPort(false);
webview.getSettings().setSupportZoom(false);
webview.getSettings().setJavaScriptEnabled(true);
webview.setBackgroundColor(Color.TRANSPARENT);
webview.loadUrl("http://www.awwwards.com/websites/responsive-design/");
RelativeLayout.LayoutParams paramsWebView = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
Dialog dialog = new Dialog(this/*put your activity object*/, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
dialog.addContentView(webview, paramsWebView);
dialog.show();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
64407 次 |
| 最近记录: |