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);