如何设置面视摄像头背景的角落 [英] How to set the surface view camera background with corner

查看:112
本文介绍了如何设置面视摄像头背景的角落的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序使用一个大小为150×150。我需要显示面角落弧型相机表面视图布局。如何设置角在照相机

My app uses a camera surface view layout with a size of 150 X 150. I need to show the surface corner is arc type. how to set the corner in camera.

<LinearLayout
    android:id="@+id/recordView"
    android:layout_width="100dp"
    android:layout_height="150dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_marginBottom="50dp"
    android:layout_marginRight="25dp" 
    android:background="@drawable/customshape">
</LinearLayout>

CUSTOMSHAPE:

customshape:

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
 android:shape="rectangle"> 
 <gradient android:startColor="#FFFFFF" android:endColor="#FFFFFF"         android:angle="270"/> 

<corners android:bottomRightRadius="50dp" android:bottomLeftRadius="50dp" 
 android:topLeftRadius="50dp" android:topRightRadius="50dp"/> 

此布局添加摄像头活动,但记录显示开始矩形视图

this layout add the camera activity but record start show the rectangle view

推荐答案

查看关于如何创建一个Android形状和形状适用于您的布局本教程:
http://www.vogella.com/blog/2011/07/ 19 / Android的形状/

Check out this tutorial on how to create an Android shape and apply that shape to your layout: http://www.vogella.com/blog/2011/07/19/android-shapes/

具体使用&LT;边角&GT; &LT属性;形状&GT; 以创建圆角,请参阅例如,从上述参考教程如下:

Specifically you use the <corners> attribute of the <shape> to create rounded corners, see example below from the above referenced tutorial:

<corners 
    android:bottomRightRadius="7dp"
    android:bottomLeftRadius="7dp" 
    android:topLeftRadius="7dp" 
    android:topRightRadius="7dp"
/>

搜索结果
更新2 - 这为我工作:

绘制,华电国际/ rounded.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"> 

    <stroke android:width="2dp" android:color="#FFFFFFFF" />

    <corners 
        android:bottomRightRadius="7dp" 
        android:bottomLeftRadius="7dp" 
        android:topLeftRadius="7dp" 
        android:topRightRadius="7dp"/> 

    <solid android:color="#00000000" />

</shape>

绘制,华电国际/ solid.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"> 

    <stroke android:width="2dp" android:color="#FFFFFFFF" />

    <solid android:color="#00000000" />

</shape>

绘制,华电国际/ rounded_inside_corners.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item android:drawable="@drawable/rounded" />
    <item android:drawable="@drawable/solid" /> 

</layer-list>

结果
然后在我的活动布局:


Then in my activity layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/my_shape"
    tools:context=".CameraActivity" >

    <SurfaceView
        android:id="@+id/surfaceView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/rounded_inside_corners"
        android:layout_above="@+id/linearLayout1" />

    <FrameLayout
        android:id="@+id/linearLayout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/buttonTakePicture"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_gravity="center_horizontal"
            android:background="@drawable/camera_click_256"
            android:gravity="center_horizontal" />
    </FrameLayout>

</RelativeLayout>

结果
这结果是:


Which results in:

这篇关于如何设置面视摄像头背景的角落的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆