Подтвердить что ты не робот

Как сделать полноэкранный просмотр в Интернете

Как сделать веб-просмотр приложения андроида в полноэкранном режиме. Я добавил webview в XML файл макета, но он не растягивается до краев макета, есть некоторый тип поля вдоль всей стороны webview. Я также добавляю изображение, чтобы дать вам ребята намек на то, что на самом деле выглядит.

What i am talking about is the space all around the webview, not the notification bar or the title bar

То, о чем я говорю, это пространство вокруг веб-браузера, а не панель уведомлений или строка заголовка

Здесь код макета:

<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>
4b9b3361

Ответ 1

Сверху кода удаляйте 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"

Он выполнит эту работу, а также обязательно удалит поля/дополнения HTML, которые вы передаете в WebView, которые могут содержать те теги, которые оставляют некоторое пространство.

Ответ 2

Просто добавьте (или измените) действие android:theme атрибут android:theme со следующей строкой в файле AndroidManifest.xml

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

Ответ 3

Android Версия: 4.2.2 - Прибор: Vega Tablet

WebView для скрытия состояния и системной панели и отображения полного экрана Я выполнил следующие шаги.

AndroidManifest.xml

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name">
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

MainActivity.java

super.onCreate(savedInstanceState);
getWindow().getDecorView().setSystemUiVisibility(0x10);
setContentView(R.layout.activity_main);
String url = "http://edition.cnn.com/";
WebView webView = (WebView) findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setUserAgentString("Desktop");
webView.loadUrl(url);

Вышеупомянутый процесс работал для меня, и мое приложение отображается в полном экране.

Ответ 4

Вы можете установить размеры в dimens.xml, найденном в папке res/values. По умолчанию это 16dp. Таким образом, можно установить его соответствующим образом.

enter image description here

Ответ 5

Вы должны изменить соответствующие настройки компоновки. И удалите настройки заполнения, если они есть в веб-просмотре в файле XML.

<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"
    tools:context=".MainActivity"
    android:id="@+id/frame">

Ответ 6

Поместите окно просмотра веб-просмотра в диалоговое окно.

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();

Ответ 7

Из документов https://developer.android.com/guide/webapps/webview.html

<?xml version="1.0" encoding="utf-8"?>
<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
/>

FILL_PARENT (переименованный MATCH_PARENT в API 8 и выше), что означает, что представление хочет быть таким же большим, как и его родительский (минус заполнение)

https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html