Android 双屏开发 Presentation 的使用教程
生活随笔
收集整理的這篇文章主要介紹了
Android 双屏开发 Presentation 的使用教程
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
使用Presentation 開發雙屏 可以把Presentation 理解為一個特殊的Dialog
如果不知道Presentation 的使用,就簡單的理解為類似自定義Dialog
下面來簡單的演示下Presentation的使用
隨便取一個名字ScreenPresentation 繼承?Presentation
由于是要展示效果,所以布局呢就隨便添加了一個背景顏色,其余的什么都沒寫
public class ScreenPresentation extends Presentation {private Context context;public ScreenPresentation(Context outerContext, Display display) {super(outerContext, display);this.context = outerContext;}@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.video_layout);}}
下面就是在Activity中使用了 Presentation
public class MainActivity extends AppCompatActivity {private ScreenPresentation screenPresentation;private DisplayManager displayManager;//屏幕管理器@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);initVideo();}private void initVideo() {if (displayManager == null) {displayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);Display[] displays = displayManager.getDisplays();//獲取窗口if (displays.length > 1) {screenPresentation = new ScreenPresentation(MainActivity.this, displays[1]);// displays[1]是副屏screenPresentation.show();//顯示}}}
}
是不是和Dialog 很類似 ,下面看下效果圖
上面就是自己給布局添加了一個顏色,具體什么自己可以根據需求在布局中添加就行,一般都是播放視頻之類的
下面就是MainActivity 里面就一個Holloword
具體demo 點擊查看把
?
總結
以上是生活随笔為你收集整理的Android 双屏开发 Presentation 的使用教程的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Could not download l
- 下一篇: 一言为定下一句是什么呢?