私のアプリケーションでは、videoview を角を丸くして表示したいと考えています。丸みを帯びた角をlinearlayoutに設定して、linearlayout内にvideoview/surfaceviewを配置しようとしました。しかし、それは完全には機能しません。videoview/surfaceview に角丸を設定できません。ビューを下の画像のように設定したい:
誰でもこれを行う方法を知っていますか?
私のアプリケーションでは、videoview を角を丸くして表示したいと考えています。丸みを帯びた角をlinearlayoutに設定して、linearlayout内にvideoview/surfaceviewを配置しようとしました。しかし、それは完全には機能しません。videoview/surfaceview に角丸を設定できません。ビューを下の画像のように設定したい:
誰でもこれを行う方法を知っていますか?
FramLayout と XML ドローアブルを使用して作成できます
フレームレイアウト
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<VideoView
android:layout_width="match_parent"
android:layout_height="@dimen/dp_240"
android:layout_margin="@dimen/dp_24"/>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/rounded_corner_video_bg" />
</FrameLayout>
XML ドローアブル
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="@dimen/dp_24"
android:color="@color/md_white_1000" />
<corners android:radius="@dimen/dp_24" />
</shape>
さまざまなビューを重ね合わせて、探している丸い角を作成してみてください。各コーナーの VideoView の上に 4 つの ImageView を配置して、目的の丸いコーナーを実現します。私はこれを達成するために RelativeLayout を使用して成功しましたが、FrameLayout を使用してビューをまとめることもできます。
直接はできませんが、videoview の上に imageview を描画し、その間が透明で角が丸い無地の画像を設定することでこれを行うことができます。これを確認してください:ここをクリック
Create an xml file in drawable folder called shape_video.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:radius="6dp" />
</shape>
Change the radius according to your rqmnt and in the background attribute of your videoview, give
android:background="@drawable/shape_video"
rounded.xml を drawable フォルダーに配置し、ビデオのフレームレイアウトに設定しますandroid:background="@drawable/rounded.xml"
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="#FFFFFFFF" />
<corners android:radius="7dp" />
</shape>