Surface View Surface View Surface View xml version1

  • Slides: 11
Download presentation

在介面佈局檔中建立Surface. View 如果希望在程式畫面中同時顯示Surface. View和其它控制元件,像是按 鈕,就必須換成在介面佈局檔中建立Surface. View元件: <? xml version="1. 0" encoding="utf-8"? > <Linear. Layout

在介面佈局檔中建立Surface. View 如果希望在程式畫面中同時顯示Surface. View和其它控制元件,像是按 鈕,就必須換成在介面佈局檔中建立Surface. View元件: <? xml version="1. 0" encoding="utf-8"? > <Linear. Layout xmlns: android="http: //schemas. android. com/apk/res/android" android: orientation="vertical" android: layout_width="match_parent" android: layout_height="match_parent" > <Surface. View android: id="@+id/cam. Preview" android: layout_width="(設定適合的寬度)" android: layout_height="(設定適合的高度)" android: layout_gravity="center_horizontal" /> ․ ․(其它介面元件) ․ </Linear. Layout> 5

範例程式 步驟一:建立一個新的Android程式專案。 步驟二:從Eclipse左邊的專案檢視視窗中開啟程式功能描述檔 Android. Manifest. xml,加入使用攝影機的相關設定,以及錄音 和寫入sd card的功能。 <? xml version="1. 0" encoding="utf-8"? >

範例程式 步驟一:建立一個新的Android程式專案。 步驟二:從Eclipse左邊的專案檢視視窗中開啟程式功能描述檔 Android. Manifest. xml,加入使用攝影機的相關設定,以及錄音 和寫入sd card的功能。 <? xml version="1. 0" encoding="utf-8"? > <manifest. . . >. . . <uses-permission android: name="android. permission. WRITE_EXTERNAL_STORAGE" /> <uses-permission android: name="android. permission. RECORD_AUDIO" /> <uses-permission android: name="android. permission. CAMERA" /> <uses-feature android: name="android. hardware. camera. autofocus" /> <application. . . > … </application> </manifest> 7

範例程式 步驟三:在Eclipse左邊的專案檢視視窗中展開此專案的 res/layout資料夾,開啟介面佈局檔main. xml,參考 前面的說明建立<Surface. View>元件標籤。這個範例 中將利用選單的方式來啟動和停止錄影,因此不需 要在介面佈局檔中加入其它元件。 <? xml version="1. 0" encoding="utf-8"? >

範例程式 步驟三:在Eclipse左邊的專案檢視視窗中展開此專案的 res/layout資料夾,開啟介面佈局檔main. xml,參考 前面的說明建立<Surface. View>元件標籤。這個範例 中將利用選單的方式來啟動和停止錄影,因此不需 要在介面佈局檔中加入其它元件。 <? xml version="1. 0" encoding="utf-8"? > <Linear. Layout xmlns: android="http: //schemas. android. com/apk/res/android" android: orientation="vertical" android: layout_width="match_parent" android: layout_height="match_parent" > <Surface. View android: id="@+id/cam. Preview" android: layout_width="match_parent" android: layout_height="match_parent" android: layout_gravity="center_horizontal" /> </Linear. Layout> 8

範例程式 Android SDK技術文件建議的影音壓縮格式設定: 標準設定, SD ( 低品質) 標準設定, SD ( 高品質) 高解析度, HD (並非所有裝置都支

範例程式 Android SDK技術文件建議的影音壓縮格式設定: 標準設定, SD ( 低品質) 標準設定, SD ( 高品質) 高解析度, HD (並非所有裝置都支 援) 影片壓縮格式 H. 264 Baseline Profile 影片解析度 176 x 144 px 480 x 360 px 1280 x 720 px 每秒影格數 (frame rate) 12 fps 30 fps 影片位元率 (bitrate) 56 Kbps 500 Kbps 2 Mbps 聲音壓縮格式 AAC-LC 聲道數目 1 (mono) 2 (stereo) 聲音位元率 (bitrate) 24 Kbps 128 Kbps 192 Kbps 10