私は自分のアプリケーションに背景としてビデオを入れようとしています。しかし、私はビデオを置くとき、それのサイズは、非常に奇妙な、時間の経過とともに上昇し、トップではありません。私はこれをどのように修正することができます誰も知っている?ビデオの背景
Activity.java
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
activity_main.xml
:種類の何か私のコード...それは側面のように切断されただけという、法的な割合でそれを残します
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/home_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<icon.com.videobackground.VideoBackground
android:id="@+id/introVideoView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<EditText
android:id="@+id/edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:hint="Enter Email"
android:padding="10dp"
android:gravity="center"
android:background="@null" />
<EditText
android:id="@+id/pass"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/edit"
android:hint="Enter Password"
android:padding="10dp"
android:layout_marginTop="5dp"
android:gravity="center"
android:background="@null" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login"
android:textColor="@android:color/holo_orange_dark"
android:padding="10dp"
android:layout_marginTop="5dp"
android:textSize="25sp"
android:background="@android:color/transparent"
android:layout_below="@+id/pass"/>
</RelativeLayout>
</RelativeLayout>
VideoBackground.java
public class VideoBackground extends SurfaceView implements SurfaceHolder.Callback {
private static final String TAG = "INTRO_VIDEO_CALLBACK";
private MediaPlayer mp;
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public VideoBackground(Context context, AttributeSet attrs,
int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init();
}
public VideoBackground(Context context, AttributeSet attrs,
int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
public VideoBackground(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public VideoBackground(Context context) {
super(context);
init();
}
private void init() {
mp = new MediaPlayer();
getHolder().addCallback(this);
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
AssetFileDescriptor afd = getResources().openRawResourceFd(R.raw.video_bgg); // your intro video file placed in raw folder named as intro.mp4
try {
mp.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(),
afd.getDeclaredLength());
mp.prepare();
} catch (IOException e) {
e.printStackTrace();
}
android.view.ViewGroup.LayoutParams lp = getLayoutParams();
int screenHeight = getHeight();
int screenWidth = getWidth();
// this plays in full screen video
lp.height = screenHeight;
lp.width = screenWidth;
setLayoutParams(lp);
mp.setDisplay(getHolder());
mp.setLooping(false);
mp.start();
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
mp.stop();
}
}
私の理解あたりとしてあなたは、[このリンク](https://stackoverflow.com/questions/8830111/integrating-video-で詳細を取得することができますアプリの背景としてのファイルアプリ) –
[アプリの背景としてのAndroidアプリの動画ファイルの統合]の可能な複製(https://stackoverflow.com/questions/8830111/integrating-video-file-in- android-app-as-app-background) –