我有一个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 file
<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>
答案 0 :(得分:0)
很多时候它只是由于命名而发生。 确保图像文件的名称和使用的图像名称相同(同时检查大写和小写字符)。