現在、以下を使用して高さと幅を設定しています。
//landsapeWebView is a WebView, and deviceHeight and deviceHeight are ints
landsapeWebView.setLayoutParams(new RelativeLayout.LayoutParams(deviceHeight, deviceWidth));
これは、一部のデバイスでは正常に機能するようですが、他のデバイスでは機能しないようです。私がたどり着いた唯一の結論は、これが高さと幅を次のように設定しているということです:
<WebView android:layout_width="(deviceWidth)dp"
android:layout_height="(deviceHeight)dp" />
私が欲しいのはこれです:
<WebView android:layout_width="(deviceWidth)px"
android:layout_height="(deviceHeight)px" />
測定単位を指定するにはどうすればよいですか?
@collusionbdbhの追加開示
display = getWindowManager().getDefaultDisplay();
if(getResources().getConfiguration().orientation == 1){
deviceWidth = display.getWidth();
deviceHeight = display.getHeight();
}else{
deviceWidth = display.getHeight();
deviceHeight = display.getWidth();
}