Androidアプリのログイン画面を作成していて、画像や簡単な色ではなく背景として動画を使用するにはどうすればいいですか?動画を背景に設定する
Spotify/Bibleアプリのログイン画面に似て、ビデオを再生し、サインインまたは登録するボタンがあります。
画像 -
(画像をクリックすると拡大します)
Androidアプリのログイン画面を作成していて、画像や簡単な色ではなく背景として動画を使用するにはどうすればいいですか?動画を背景に設定する
Spotify/Bibleアプリのログイン画面に似て、ビデオを再生し、サインインまたは登録するボタンがあります。
画像 -
(画像をクリックすると拡大します)
まず新しいXML
を作り、その中にVideoView
を追加します。
my_video_background.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<VideoView
android:id="@+id/videoView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_gravity="center" />
</RelativeLayout>
その後Buttons
を持って、あなたのメインのレイアウトの内側にこのファイルを含め、のは言わせて:
splash.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#29000000">
<include layout="@layout/my_video_background" />
<!--Like Spotify image-->
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="46dp"
android:src="@android:drawable/ic_dialog_map" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<Button
android:id="@+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:background="#FF2D2D2D"
android:text="LOG IN"
android:textColor="@android:color/white" />
<Button
android:id="@+id/signUp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:background="#FF669900"
android:text="SIGN IN"
android:textColor="@android:color/white" />
</LinearLayout>
</RelativeLayout>
それだそれ!
ビューページャは映像が左から右に全画面追加するストレッチしますので、VideoViewでは、いくつかのtransparend背景 –
とレイアウトに追加する必要があるため、私は思う: アンドロイド:layout_alignParentEnd =「true」を アンドロイド:layout_alignParentStart = "真の" –
ビデオをアプリの背景として設定するには、いくつかの手順が必要です。
VideoView videoview = (VideoView) findViewById(R.id.videoview); Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.test); videoview.setVideoURI(uri); videoview.start();を再生する「生」ディレクトリ
これは動作しています、兄弟ありがとう! –
NatureDevilの答えとビデオは素晴らしいですが、あなたはボタンをクリックし、新しい活動を開くと2つのことのような最初に欠けています歌うアップし、デバイス上の戻る矢印をクリックすることを決定したビデオは、あなたがVideoViewは左からストレッチするため、この
@Override
protected void onResume() {
super.onResume();
// to restart the video after coming from other activity like Sing up
mVideoView.start();
}
他の事を追加する必要はありそうに再起動しませんので、ホーム画面が黒い画面を与えます完全なフルスクリーンの追加:
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
この問題は解決しますか? – exequielc