我在FrameLayout中放置了视频观看和图像视图,我在全屏播放视频时遇到问题。
SplashScreen屏幕截图:
layout-land / splashscreen.xml (横向广告的Splashscreen布局):
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:id="@+id/frame"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<VideoView
android:id="@+id/VideoView"
android:layout_height="wrap_content"
android:layout_width="fill_parent" ></VideoView>
<ImageView
android:id="@+id/welcomelogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/welcomelogo"
android:layout_gravity="center_vertical|center" />
</FrameLayout>
layout / splashscreen.xml (肖像的Splashscreen布局):
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:id="@+id/frame"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<VideoView
android:id="@+id/VideoView"
android:layout_height="fill_parent"
android:layout_width="wrap_content" ></VideoView>
<ImageView
android:id="@+id/welcomelogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/welcomelogo"
android:layout_gravity="center_vertical|center" />
</FrameLayout>
SplashScreen.java:
package com.conquer.casino;
import com.conquer.casino.R;
import com.plattysoft.leonids.ParticleSystem;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.drawable.AnimationDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.provider.ContactsContract.CommonDataKinds.Relation;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.animation.AccelerateInterpolator;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.MediaController;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.VideoView;
public class SplashScreen extends Activity {
ImageView imageview;
private RelativeLayout parent;
int modeChange;
private MediaController mc;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.splashscreen);
int orientation = getResources().getConfiguration().orientation;
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
//modeChange = 1;
} else if (orientation == Configuration.ORIENTATION_PORTRAIT) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
//modeChange = 2;
}
VideoView vd = (VideoView) findViewById(R.id.VideoView);
Uri uri = Uri.parse("android.resource://" + getPackageName() + "/"+R.raw.trimmedvideo);
mc = new MediaController(this);
vd.setMediaController(mc);
vd.setMediaController(null);
vd.setVideoURI(uri);
vd.start();
// Start long running operation in a background thread
new Thread() {
public void run() {
try {
sleep(4000);
} catch (InterruptedException e) {
e.printStackTrace();
}
finally{
Intent intent = new Intent(SplashScreen.this,HomeActivity.class);
startActivity(intent);
finish();
}
}
}.start();
}
/*public void onClick(View v) {
try {
ParticleSystem ps = new ParticleSystem(this, 1000, R.drawable.starpink, 5000);
ps.setScaleRange(0.7f, 0.3f);
ps.setSpeedRange(0.01f, 0.55f);
ps.setAcceleration(0.00001f, 10);
ps.setRotationSpeedRange(1000, 580);
ps.setFadeOut(10, new AccelerateInterpolator());
ps.oneShot(v, 100);
ParticleSystem ps1 = new ParticleSystem(this, 10000, R.drawable.starwhite, 5000);
ps1.setScaleRange(0.7f, 0.3f);
ps1.setSpeedRange(0.01f, 0.55f);
ps1.setAcceleration(0.00001f, 10);
ps1.setRotationSpeedRange(1000, 180);
ps1.setFadeOut(10, new AccelerateInterpolator());
ps1.oneShot(v, 500);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
new ParticleSystem(this, 100, R.drawable.starpink, 800)
.setSpeedRange(0.1f, 0.25f)
.oneShot(v, 100);
} */
}
的Manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<![manifest][2] xmlns:android="http://schemas.android.com/apk/res/android"
package="com.conquer.casino"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<application
android:allowBackup="true"
android:allowClearUserData="false"
android:largeHeap="true"
android:icon="@drawable/appicon"
android:label="@string/app_name"
android:manageSpaceActivity="com.conquer.casino.ManageSpace"
android:theme="@style/AppTheme" >
<activity
android:name="com.conquer.casino.SplashScreen"
android:label="@string/app_name"
android:theme="@style/MyApp.Theme.Light.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- android:configChanges="keyboardHidden|screenLayout|orientation|fontScale|uiMode" -->
<activity
android:name="com.conquer.casino.HomeActivity"
android:screenOrientation="sensor"
android:theme="@style/MyApp.Theme.Light.NoTitleBar"
android:windowSoftInputMode="stateHidden" >
</activity>
<activity
android:name="com.conquer.casino.GameListActivity"
android:configChanges="keyboardHidden|screenLayout|orientation|fontScale|uiMode"
android:screenOrientation="sensor"
android:theme="@style/MyApp.Theme.Light.NoTitleBar"
android:windowSoftInputMode="stateHidden" >
</activity>
<activity
android:name="com.conquer.casino.GameActivity"
android:configChanges="keyboardHidden|screenLayout|orientation|fontScale|uiMode"
android:screenOrientation="sensor"
android:theme="@style/MyApp.Theme.Light.NoTitleBar"
android:windowSoftInputMode="stateHidden" >
</activity>
<activity
android:name="com.conquer.casino.ManageSpace"
android:configChanges="keyboardHidden|screenLayout|orientation|fontScale|uiMode"
android:screenOrientation="sensor"
android:theme="@style/MyApp.Theme.Light.NoTitleBar"
android:windowSoftInputMode="stateAlwaysHidden" >
</activity>
<activity
android:name="com.conquer.casino.PlayForRealBtn"
android:configChanges="keyboardHidden|screenLayout|orientation|fontScale|uiMode"
android:screenOrientation="sensor"
android:theme="@style/MyApp.Theme.Light.NoTitleBar"
android:windowSoftInputMode="stateHidden" >
</activity>
<receiver
android:name="com.mobileapptracker.Tracker"
android:exported="false" >
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<meta-data
android:name="com.google.android.gms.version"
android:value="4242000" /> <!-- 3136130 -->
</application>
</manifest>
答案 0 :(得分:1)
使用FrameLayout有什么特别的理由吗? 我使用RelativeLayout并且它的工作正常和全屏都做到了。以下是代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/frame"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<VideoView
android:id="@+id/VideoView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
</VideoView>
<ImageView
android:id="@+id/welcomelogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center"
android:background="@drawable/ic_launcher" />
</RelativeLayout>