欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android 谷歌推薦的VR實現方式(分享)

 更新時間:2018年01月18日 10:01:31   作者:鍵盤舞者113  
下面小編就為大家分享一篇Android 谷歌推薦的VR實現方式。具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

谷歌有專門的SDK來完成VR,我這次以一個全景圖片的例子來說一下這個SDK實現VR的基本過程,首先全景圖片就是百度地圖里的那樣,能夠看到周圍環(huán)境360的圖片。

添加依賴

compile 'com.google.vr:sdk-panowidget:1.80.0'

添加權限

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.GET_TASKS"/>

實現代碼

public class GoogleVRActivity extends AppCompatActivity {
 private VrPanoramaView mVrPanoramaView;
 private VrPanoramaView.Options paNormalOptions;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_google_vr);
  initVrPaNormalView();
 }
 @Override
 protected void onPause() {
  super.onPause();
  mVrPanoramaView.pauseRendering();
 }
 @Override
 protected void onResume() {
  super.onResume();
  mVrPanoramaView.resumeRendering();
 }
 @Override
 protected void onDestroy() {
  // Destroy the widget and free memory.
  super.onDestroy();
  mVrPanoramaView.shutdown();
 }

 //初始化VR圖片
 private void initVrPaNormalView() {
  mVrPanoramaView = (VrPanoramaView) findViewById(R.id.mVrPanoramaView);
  paNormalOptions = new VrPanoramaView.Options();
  paNormalOptions.inputType = VrPanoramaView.Options.TYPE_STEREO_OVER_UNDER;
//  mVrPanoramaView.setFullscreenButtonEnabled (false); //隱藏全屏模式按鈕
  mVrPanoramaView.setInfoButtonEnabled(false); //設置隱藏最左邊信息的按鈕
  mVrPanoramaView.setStereoModeButtonEnabled(false); //設置隱藏立體模型的按鈕
  mVrPanoramaView.setEventListener(new ActivityEventListener()); //設置監(jiān)聽
  //加載本地的圖片源
  mVrPanoramaView.loadImageFromBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.andes), paNormalOptions);
  //設置網絡圖片源
//  panoWidgetView.loadImageFromByteArray();
 }
 private class ActivityEventListener extends VrPanoramaEventListener {
  @Override
  public void onLoadSuccess() {//圖片加載成功
  }

  @Override
  public void onLoadError(String errorMessage) {//圖片加載失敗
  }
  @Override
  public void onClick() {//當我們點擊了VrPanoramaView 時候觸發(fā)   super.onClick();
  }
  @Override
  public void onDisplayModeChanged(int newDisplayMode) {
   //改變顯示模式時候出發(fā)(全屏模式和紙板模式)
   super.onDisplayModeChanged(newDisplayMode);
  }
 }
}
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:background="@android:color/white">
 <LinearLayout
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:padding="10dip"
  android:id="@+id/main_layout"
  android:orientation="vertical" >
  <TextView
   style="@style/ContentText"
   android:id="@+id/title"
   android:textSize="@dimen/title_text_size"
   android:textStyle="bold"
   android:textColor="@color/colorAccent"
   android:text="第二種谷歌官方VR演示" />
  <TextView
   style="@style/ContentText"
   android:id="@+id/subtitle"
   android:textColor="@color/colorAccent"
   android:textSize="@dimen/caption_text_size"
   android:text="谷歌紙殼子demo" />
  <TextView
   style="@style/ContentText"
   android:id="@+id/paragraph1"
   android:textColor="@color/colorAccent"
   android:textSize="@dimen/paragragh_text_size"
   android:text="魚和熊掌不可兼得" />
  <com.google.vr.sdk.widgets.pano.VrPanoramaView
   android:id="@+id/mVrPanoramaView"
   android:layout_width="match_parent"
   android:layout_height="250dip"/>

 </LinearLayout>
</ScrollView>

VrPanoramaView這個類和Activity有著類似的生命周期,全屏顯示是它自己設置的,這個VR 的SDK完成度很高,可以多去參考。

以上這篇Android 谷歌推薦的VR實現方式(分享)就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關文章

  • Android使用BroadcastReceiver監(jiān)聽網絡連接狀態(tài)的改變

    Android使用BroadcastReceiver監(jiān)聽網絡連接狀態(tài)的改變

    這篇文章主要為大家詳細介紹了Android使用BroadcastReceiver監(jiān)聽網絡連接狀態(tài)的改變,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-05-05
  • Android TreeView效果實現方法(附demo源碼下載)

    Android TreeView效果實現方法(附demo源碼下載)

    這篇文章主要介紹了Android TreeView效果實現方法,結合實例形式分析了Android TreeView效果的實現原理與具體技巧,并附帶demo源碼供讀者下載,需要的朋友可以參考下
    2016-02-02
  • android創(chuàng)建optionsmenu的方法

    android創(chuàng)建optionsmenu的方法

    這篇文章主要介紹了android創(chuàng)建optionsmenu的方法,實例分析了Android菜單項的設置與創(chuàng)建技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-07-07
  • Android傳遞參數給webView的h5頁面3種方法

    Android傳遞參數給webView的h5頁面3種方法

    最近幾年隨著h5的強勢崛起,越來越多的公司運用h5開發(fā)或者采用h5與android的混合開發(fā),這篇文章主要給大家介紹了關于Android傳遞參數給webView的h5頁面的3種方法,需要的朋友可以參考下
    2024-08-08
  • 詳解Android中weight的使用方法

    詳解Android中weight的使用方法

    這篇文章主要向大家介紹了詳解Android中weight的使用方法,感興趣的小伙伴們可以參考一下
    2016-01-01
  • Android 無障礙全局懸浮窗實現示例

    Android 無障礙全局懸浮窗實現示例

    本文主要介紹了Android 無障礙全局懸浮窗實現示例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2022-06-06
  • 基于Android week view仿小米和iphone日歷效果

    基于Android week view仿小米和iphone日歷效果

    這篇文章主要為大家詳細介紹了基于Android week view仿小米和iphone日歷效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-11-11
  • 基于Android實現轉盤按鈕代碼

    基于Android實現轉盤按鈕代碼

    這篇文章主要介紹了基于Android實現轉盤按鈕代碼的相關資料,需要的朋友可以參考下
    2015-12-12
  • android實現簡單圓弧效果

    android實現簡單圓弧效果

    這篇文章主要為大家詳細介紹了android實現簡單圓弧效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-08-08
  • Android TabHost組件使用方法詳解

    Android TabHost組件使用方法詳解

    這篇文章主要以實例講解的方式為大家詳細介紹了Android TabHost組件的使用方法,感興趣的小伙伴們可以參考一下
    2016-05-05

最新評論