Android Web View looks weird on Tablet but fine on emulator in Android Studio

Tags: , , , ,



I made a WebView and the site looks completely fine on the Emulator but when I install the APK on my Samsung Galaxy Tab A it looks really messed up.

This is what it’s supposed to look like: enter image description here

and this is what it looks like on my tablet:

enter image description here enter image description here

I have 3 xml files:

activity_webappview.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="fill_parent"
    android:orientation="horizontal"
    android:layout_height="fill_parent"
    tools:context="com.cwm.cwmapp.webappview">

    <WebView
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <Button
            android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"
            android:text=""
            tools:layout_editor_absoluteX="2dp"
            tools:layout_editor_absoluteY="2dp" />
    </WebView>
</RelativeLayout>

content_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".webappview"
    tools:showIn="@layout/activity_main">



</android.support.constraint.ConstraintLayout>

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_main" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        app:srcCompat="@android:drawable/ic_dialog_email" />

</android.support.design.widget.CoordinatorLayout>

I tried to mess around with them a bit but it only ever changed the results in the emulator and would always stay the same on the tablet.

Does anybody know why it looks so messed up on the tablet?

Answer

Found the issue. Since this was loaded from files and not an actual website, I couldn’t access the referenced stylesheet which was a link to an online stylesheet.

Turns out the button could stay after all… :^)



Source: stackoverflow