【发布时间】:2017-04-28 04:57:16
【问题描述】:
我正在开发一个应用程序,我想要在 WebView 上显示图像(图像在 WebView 之上)。我搜索了谷歌并尝试了很多东西。但它不起作用。
在 XML 的设计选项卡中,我可以在 WebView 上看到图像。但是当我在手机中加载应用程序时,图像不会出现,但网页会加载。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
xmlns:fab="http://schemas.android.com/tools">
<ImageView
android:id="@+id/fabButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:layout_marginRight="24dp"
app:srcCompat="@drawable/imag1"
android:elevation="2dp"
android:layout_marginEnd="41dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
/>
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webView"
android:layout_gravity="center_horizontal"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
提前感谢您的帮助。 我不知道它是否会影响代码,但我正在尝试在片段中执行此操作
【问题讨论】:
-
在您的 web 视图之后添加您的图像视图。 ViewGroup 主要以孩子先到先得为基础,因此在您的代码中 webviews 隐藏了 ImageView