您的位置:首页 > 移动开发

android webview显示文字和图片

2014-01-17 13:26 811 查看
先上图看效果:


评价内容这一块就是用了webview

布局代码,跟平常的view没有什么区别

<WebView
android:id="@+id/view_evaluation_list_item_bottom_webview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="-5dp"
/>


上关键代码:

mViewHolder.rateWebview.loadDataWithBaseURL("file:///android_asset/image/"
, String.format(getString(R.string.view_evaluation_webview_data)
, evaluationGrade, String.valueOf(imageUrl), evaluationContent)
, "text/html"
, "utf-8"
, null);

注意:

file:///android_asset/image/

这表示将图片放在了项目的assets(本来就有的)文件夹下的image(自己新建的)文件夹下
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: