android:camera rotate90 使用相機時旋轉90度問題

由於很多android手機在使用相機的豎屏模式的時候,相機的preview有旋轉了90度而看起來非常醜的問題,所以只有使用默認的橫屏模式來獲取圖像。


1.在androidManifest.xml中申明只能使用橫屏

<activity android:name=".ui.SnapActivity" android:screenOrientation="landscape" />

2.在surface.xml中提供提示用戶當時是橫屏還是豎屏的標誌(比如有方向性的圖片或者文字描述)

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
	xmlns:android="http://schemas.android.com/apk/res/android"
	android:layout_width="fill_parent"
	android:layout_height="fill_parent">
    <SurfaceView android:id="@+id/surfaceCamera"
		android:layout_width="fill_parent"
		android:layout_height="fill_parent"
		android:layout_weight="1"
	/>
	<LinearLayout android:layout_width="wrap_content"
		android:orientation="horizontal"
		android:layout_height="fill_parent"
		android:gravity="center_vertical"
		android:layout_alignParentRight="true">
		<ImageView android:id="@+id/snapBtn"
			android:src="@drawable/snap_land"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_gravity="center_vertical"
			android:layout_marginRight="10dp"/>
	</LinearLayout>
  	<TextView android:text="Here we go"
  		android:textSize="10pt"
  		android:textColor="#00fff0"
  		android:layout_width="fill_parent"
  		android:layout_height="wrap_content"
  		android:layout_alignParentTop="true"
  		android:layout_alignParentLeft="true"
  		android:gravity="center_horizontal"/>
</RelativeLayout>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章