2017-01-23 46 views
0

This is instagram app我有一个表面视图(匹配父母匹配父项)的活动,其中一半隐藏按钮。是否可以只保存拍摄图片的可见部分?我试图让表面视图更小,但预览在这种情况下旋转或拉伸。我使用android.hardware.camera1顺便说一句如何从相机预览(表面视图)裁剪图像,并保存它,而不是像instagram应用程序的实际图像捕获bt相机?

<?xml version="1.0" encoding="utf-8"?> 
 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 
    xmlns:tools="http://schemas.android.com/tools" 
 
    android:id="@+id/activity_camera" 
 
    android:layout_width="match_parent" 
 
    android:layout_height="match_parent" 
 

 
    tools:context="uz.pages.yangiuz10.activity.CameraActivity"> 
 

 
    <SurfaceView 
 
     android:layout_width="match_parent" 
 
     android:layout_height="match_parent" 
 
     android:id="@+id/surface_camera"/> 
 

 

 
    <LinearLayout 
 
     android:layout_width="match_parent" 
 
     android:layout_height="match_parent" 
 
     android:orientation="vertical"> 
 

 
     <View 
 
      android:layout_width="match_parent" 
 
      android:layout_height="0dp" 
 
      android:layout_weight="1"/> 
 

 
     <RelativeLayout 
 
      android:layout_width="match_parent" 
 
      android:layout_height="0dp" 
 
      android:layout_weight="1" 
 
      android:background="@color/colorBackgroundText"> 
 

 
      <ImageButton 
 
       android:layout_width="wrap_content" 
 
       android:layout_height="wrap_content" 
 
       android:id="@+id/button_shot" 
 
       android:layout_centerHorizontal="true" 
 
       android:layout_centerVertical="true" 
 
       android:src="@drawable/shot_btn" 
 
       android:background="@null" 
 
       android:onClick="onPictureCapture"/> 
 

 
     </RelativeLayout> 
 
    </LinearLayout> 
 

 

 
</RelativeLayout>

Need to save only that visible part of image

+0

您使用surfaceView宽度和高度[match_parent在.XML..that就是为什么它会捕捉图像在全屏模式下......即使你确实隐藏了SurfaceView的下面部分 –

+0

它在运行时需要全尺寸的表面视图预览...我也有同样的Problem.i也隐藏了我的SurfaceView部件,和你一样..区别在于你隐藏button.and我隐藏布局 –

+0

我裁剪我捕获的图像。因为我没有找到了任何解决方案。 –

回答

相关问题