0
要显示图像,我选择使用Webview组件,因为它允许轻松进行交互式缩放。Android - Webview - 旋转图像和缩放以适应页面宽度
我该如何首先旋转图像90,然后缩放结果以适应webview/screen的全部宽度?
这就是我所做的,但只显示一个小图像。全宽未使用。
WebView infoT = (WebView)rootView.findViewById(R.id.picture_show);
infoT.getSettings().setDefaultTextEncodingName("utf-8");
infoT.getSettings().setSupportZoom(true);
infoT.getSettings().setBuiltInZoomControls(true);
infoT.loadDataWithBaseURL(null, "<html><head><style>img{ -webkit-transform: rotate(90deg); max-width: 100%; }</style></head><body><img src=\"file://" + pictureFile + "\"/></body></html>", "text/html", "utf-8", null);
片段的布局文件是:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<WebView
android:id="@+id/picture_show"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:scrollbars="vertical" />
</RelativeLayout>
我也尝试过类似的选项:
infoT.loadDataWithBaseURL(null,"<!DOCTYPE html><html><body style =\"text-align:center\"><img style=\"border-style:dotted;border-width:5px;border-color:black;width:99%;-webkit-transform: rotate(90deg);\" src=\"file://" + pictureFile + "\"/></body></html>","text/html", "UTF-8", null);