在我的应用程序中,我想将视频视图显示为圆角。我尝试将videoview / surfaceview放置在linearlayout内,并将圆角设置为linearlayout。但它并不完美。我无法将圆角设置为videoview / surfaceview。我想将视图设置如下图:
任何人都知道如何做到这一点?
它对我有用,
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_gravity="center"
android:layout_width="match_parent"
card_view:cardCornerRadius="25dp"
android:layout_height="wrap_content">
<VideoView
android:id="@+id/video"
android:layout_width="match_parent"
android:layout_height="215dp" />
</android.support.v7.widget.CardView>
您可以尝试将不同的视图叠加在一起,以创建您正在寻找的圆角。尝试在每个角落的VideoView上放置四个ImageView,以获得所需的圆角。我已成功使用RelativeLayout来完成此任务,但您也可以尝试使用FrameLayout将视图保持在一起。
这是直接不可能的,但是你可以通过在videoview上绘制一个imageview并设置一个透明的图像和角上的圆角形状的纯色来实现。检查一下:Click here
您可以使用FramLayout和XML drawable来创建它
直到布局
<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 Drawable
<?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>
将rounded.xml放在drawable文件夹中,并在像android:background="@drawable/rounded.xml"
这样的视频的framelayout上设置
<?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>
在drawable文件夹中创建一个名为shape_video.xml的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>
根据您的rqmnt和视频视图的背景属性更改半径,给出
android:background="@drawable/shape_video"