【发布时间】:2020-06-12 12:59:15
【问题描述】:
我制作了一个 WebView,网站在模拟器上看起来完全正常,但是当我在三星 Galaxy Tab A 上安装 APK 时,它看起来真的很乱。
这就是我平板电脑上的样子:
我有 3 个 xml 文件:
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>
我试着弄乱他们一点,但它只会改变模拟器中的结果,并且在平板电脑上总是保持不变。
有人知道为什么它在平板电脑上看起来如此混乱吗?
【问题讨论】:
-
WebView不是为生孩子而设计的,所以我预计WebView尝试持有Button会产生奇怪的结果。 -
在@CommonsWare 之前该按钮从未有任何问题,我只是将其删除以测试它是否会改变任何东西。问题持续存在。
-
但是不要这样做,因为它会导致其他问题。如果它不是为那样使用而设计的,你为什么要这样做?
-
我已经说过我删除了它,重复评论同一件事毫无意义,尤其是因为它与我的问题毫无关系。
-
这可能是引导问题还是什么?由于组件确实获得了全宽,因此网站似乎在猜测您使用的是手持设备,并且正在为您的设备显示优化的布局。这可能是由于您的显示器分辨率低或浏览器使用了不同的代理。有关如何处理此外观的更多信息:stackoverflow.com/questions/14688030/…
标签: java android xml android-studio tablet