Sunday, 1 November 2020

How to fill screen with rotated webview?

When I rotate the webview it does not fill the screen.

I want to rotate the webview because AndroidTV requires landscape mode... but we are gonna have the TV in a portrait setting.

i use fill_parent && match_parent but it does not work in either case.

here is a screen shot of Android Studio preview.

Also to note when i test it like this it seems like the webview matchs the screen size but doesn't adapt to the rotation... it just rotates the webview and does not resize it to the new dimensions

rotated webview not filling parent

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_centerInParent="true"
    android:background="@drawable/game_bg"
    android:orientation="vertical"

    tools:context="com.surveyswithgames.app.wheel.KeypadActivity">
    <FrameLayout
        android:id="@+id/frameParent"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerHorizontal="true"
        android:layout_centerInParent="true"
        android:layout_gravity="center"
        android:layout_marginLeft="2dp"
        android:layout_marginStart="2dp"
        android:layout_marginTop="2dp"
        android:background="@android:color/transparent"
        android:foregroundGravity="center"
        android:keepScreenOn="true">
        <WebView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/keypadWebView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:rotation="-90"
            />

    </FrameLayout>
</RelativeLayout>


from How to fill screen with rotated webview?

No comments:

Post a Comment