0

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?

Baddl
  • 43
  • 5
  • 3
    A `WebView` is not designed to have children, so I would expect strange results from having a `WebView` attempt to hold a `Button`. – CommonsWare Jun 12 '20 at 13:01
  • Never had any problems with that button before @CommonsWare, I just removed it to test if it would change anything. Problem sustains. – Baddl Jun 12 '20 at 13:05
  • But just don't do it because it can cause other problems. Why should you do it if it is not designed to be used that way? – larsaars Jun 12 '20 at 13:36
  • I already said I removed it, no point in commenting the same thing twice, especially because it’s in no way related to my question. – Baddl Jun 12 '20 at 14:03
  • Could that be a bootstrap issue or something? As the components did get full width it looks like the website is guessing you are using a handheld and is showing a optimized layout for your device. This could be caused by low resolution of your display or the browser is using a different agent. For further information how to handle this look here: https://stackoverflow.com/questions/14688030/setting-webview-to-view-desktop-site-and-not-mobile-site – Hatzen Jun 12 '20 at 14:45
  • Thanks Hatzen this was actually the only useful tip and led me in the right direction. – Baddl Jun 12 '20 at 18:53

1 Answers1

0

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... :^)

Baddl
  • 43
  • 5