【问题标题】:How to design a video view with curved edges in android?如何在android中设计具有弯曲边缘的视频视图?
【发布时间】:2015-09-09 06:43:56
【问题描述】:

在我的应用程序中,我想将 videoview 显示为圆角。我尝试将 videoview 放置在线性布局内,圆角设置为线性布局。但它并不完美。我无法将圆角设置为 videoview。那么如何设计带有弯曲边缘的videoview呢?

【问题讨论】:

  • 在 VideoView 上面加一个遮罩怎么样?

标签: android android-layout android-drawable android-videoview


【解决方案1】:

在名为 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>

根据您的要求更改半径并在视频视图的背景属性中,给

android:background="@drawable/shape_video"

【讨论】:

  • 是的,我以同样的方式尝试过它仍然无法正常工作
  • 应该可以,你能把你所有的xml文件贴在这里吗?有问题更新!!
【解决方案2】:

您指定可绘制对象:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners android:radius="10dip"/>
    <stroke
    android:width="5dip"
    android:color="@color/blue" />
</shape>

然后你必须将drawable指定为前景:

<LinearLayout
    android:id="@+id/layout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:foreground="@drawable/border"
    android:padding="5dp">
    <VideoView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/VideoView1"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent" />
</LinearLayout>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多