【发布时间】:2014-04-20 07:19:12
【问题描述】:
我有一个 html 文件,其中包含图像。当我尝试使用 webview 加载该 html 文件时,html 文件加载但图像没有。
主活动文件代码(activity_about)
webviewAbout=(WebView)findViewById(R.id.webview_about);
webviewAbout.loadUrl("file:///android_asset/about.html");
activity_about.xml 代码
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity"
tools:ignore="NestedWeights,UselessParent" >
<!-- main layout -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.10"
android:orientation="horizontal"> <!-- First layout -->
<ImageButton
android:id="@+id/ibtn_about_back"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:scaleType="center"
android:layout_weight="0.2"
android:src="@drawable/backiconlogo" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:scaleType="fitXY"
android:src="@drawable/paniclogo" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight="0.80"
android:background="@color/TechWhite">
<WebView
android:id="@+id/webview_about"
android:layout_height="fill_parent"
android:layout_width="fill_parent"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight="0.10"
android:background="@color/TechWhite">
<Button
android:id="@+id/btn_exit_about"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:text="Exit"
android:padding="10dp"
android:layout_marginLeft="150dp"
android:textSize="15sp"
android:layout_gravity="center"
android:background="@color/Blackish_Yellow"
android:textColor="@color/Brownnish"/>
</LinearLayout>
</LinearLayout>
about.html 文件
<html>
<head> <h2 align="center">About</h2>
<h2 align="center">Panic App</h2>
<title>
</title>
</head>
<body bgcolor="#f8f8ec">
<h1 align="center"><img src="E:\PANIC APP\assets\images\Paniclogo.png"/></h1>
<p align="center">Version 1.0</p>
<p align="center"></br>The “Panic App” is a emergency kind Application that it will help you out to get out of any “Emergency” situation by sending you help at the place you are.</p>
<p align="center">It will also guide you that what “Primary” measure you should take during such Panic situation.</p>
</body>
</html>
【问题讨论】:
-
我在您的布局文件中没有看到任何网页视图?
-
他们的....好好检查一下...
-
抱歉,完全错过了:)
-
你能分享一下about.html吗?可能图片的 src 无法访问。
-
这个
E:\PANIC APP\assets\images\Paniclogo.png是您本地文件系统的路径。 Android 将无法加载此文件,因为它未存储在设备的存储空间中。检查这个相关问题:stackoverflow.com/questions/3779789/…
标签: android