[英]Android: Only rotate webview, not the menu buttons on the phone
在我的应用中,我显示的网页太大,无法容纳在人像显示器上,因此我想旋转它。 我尝试使用RequestedOrientation = ScreenOrientation.Landscape;
活动,但它会更改整个手机的轮播,而不仅仅是Webview。 我也尝试制作一个自定义的webview类:
public class VerticalWebView : WebView
{
bool topDown = true;
public VerticalWebView(Context context, IAttributeSet attrs) : base(context, attrs)
{
}
public override void Draw(Canvas canvas)
{
if (topDown)
{
canvas.Translate(Height, 0);
canvas.Rotate(90);
}
else
{
canvas.Translate(0, Width);
canvas.Rotate(-90);
}
canvas.ClipRect(0, 0, Width, Height, Region.Op.Replace);
base.Draw(canvas);
}
}
但我无法使其与布局文件中的Webview XML一起使用。 任何投入将不胜感激
如果我的要求不对,请纠正我
首先直接指示手机的方向如何检测android设备的方向?
检查并在正确的条件下
根据需要旋转webView
! 像下面
WebView webView = (WebView) findViewById(R.id.web);
webView.loadUrl("https://stackoverflow.com/questions/1930963/rotating-a-view-in-android");
webView.setRotation(90);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.