im making an android app for an existing website using webview... and i have a problem with the media player... it runs fine but when u click fullscreen it kinda focuses in certain area in the video and does not shrink the video to the right size .. but when i flip the phone to landscape mode everything is fine... so i need help to make the app flip to landscape mode when i click on full screen and retus to portrait mode when i exit fullscreen mode (i waa keep the app in portrait mode all time except when clicking full screen on the video)...here is my app so far:
MainActivity:
public class MainActivity extends Activity {
WebView myWebView;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myWebView = (WebView) findViewById(R.id.webView1);
WebSettings webSettings = myWebView.getSettings();
webSettings.setLoadWithOverviewMode(true);
webSettings.setUseWideViewPort(true);
webSettings.setJavaScriptEnabled(true);
myWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {//this is for handling the white screen that appears while loading
super.onPageFinished(view, url);
//show webview
findViewById(R.id.webView1).setVisibility(View.VISIBLE);
//hide loading image
findViewById(R.id.pv1).setVisibility(View.INVISIBLE);
}
});
myWebView.loadUrl("************");
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="e.a.nasrat.hela.MainActivity">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webView1"
android:visibility="gone"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/pv1"
android:visibility="visible"
android:src="@mipmap/splash" />
</RelativeLayout>
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="e.a.nasrat.hela">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/logo"
android:label="HELA"
android:supportsRtl="true"
android:theme="@android:style/Theme.NoTitleBar"
android:name="Hela"
android:screenOrientation="portrait">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
