2017-04-20 3 views
0

ビデオをwebviewに読み込もうとしています。それはうまく動作します。データを読み込むAndroid Webviewで画面に表示する高さと幅を合わせます

しかし、私のビデオは小さいサイズで読み込まれています。

私のコードは以下の通りです:

webView.loadData("<html><body> <script type='text/javascript'>ch='" + ChId + "'; ch_width=1080; ch_height=720;</script><script type='text/javascript' src='http://m.s247.tv/live.js'></script> </body></html>", "text/html; charset=utf-8", "UTF-8"); 

私は映像が画面に合うようにしたいです。

+0

@マハーリスアドティアが動作しない –

+0

@Maharith Aditya Please Example –

答えて

2

ディスプレイの幅と高さを取得します。

DisplayMetrics displayMetrics = new DisplayMetrics(); 
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); 
int width = displayMetrics.widthPixels; 
int height = displayMetrics.heightPixels; 

は、その後のWebビューで、幅と高さを設定します。

webView.loadData("<html><body> <script type='text/javascript'>ch='" + ChId + "'; ch_width="+ width +"; ch_height=" + height" +";</script><script type='text/javascript' src='http://m.s247.tv/live.js'></script> </body></html>", "text/html; charset=utf-8", "UTF-8"); 

あなたもアスペクト比を計算し、アスペクト比と高さを設定することができます。

関連する問題