使用相机拍摄指定区域,自己封装了个工具类,直接使用就可以
代码使用如下
public class MainActivity extends Activity implements OnClickListener {
private FacadeView facade; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); facade=(FacadeView) findViewById(R.id.facade); facade.setTransParentRectWH(300, 300); findViewById(R.id.btn_shutter).setOnClickListener(this); } @Override public void onClick(View v) { facade.takeRectPicture(true); }}<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <com.szm.cameratest2.utils.view.FacadeView android:id="@+id/facade" android:layout_width="fill_parent" android:layout_height="fill_parent" /> <ImageButton android:id="@+id/btn_shutter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginBottom="10dip" android:background="@drawable/btn_shutter_background" /> </RelativeLayout>下载代码:链接: http://pan.baidu.com/s/1hr0F5nm 密码: aecf