WebViewのみを回転させ、他には何も回転させない場合は、次のようなカスタムWebViewを作成します。
public class VerticalWebView extends WebView {
final boolean topDown = true;
public VerticalWebView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public void draw(Canvas canvas) {
if (topDown) {
canvas.translate(getHeight(), 0);
canvas.rotate(90);
} else {
canvas.translate(0, getWidth());
canvas.rotate(-90);
}
canvas.clipRect(0, 0, getWidth(), getHeight(), android.graphics.Region.Op.REPLACE);
super.draw(canvas);
}
}
topDown
(逆に回転させたい場合はfalseに変更してください)
次に、XMLで次のように使用します。
<com.my.package.VerticalWebView
android:id="@+id/myview"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</com.my.package.VerticalWebView>
これは画面に表示されているビューを回転させるだけであり、タッチ座標を対応するポイントの新しい位置に再マップしないため、リンクなどは機能しないことに注意してください。