简体   繁体   English

Android:不同的组件对应不同的屏幕

[英]Android: different components for different screens

I need to create an application similar to file browser - with opportunity to move through the files tree and looking into files.我需要创建一个类似于文件浏览器的应用程序 - 有机会在文件树中移动并查看文件。

What I want - is to make one app for both phone and tablet.我想要的是为手机和平板电脑制作一个应用程序。

On tablet I want it to look like "Split View Based Application" on IPad On phone I want to have something like a button which shows the activity with files tree (which will be on the left on tablet)在平板电脑上,我希望它看起来像 IPad 上的“基于拆分视图的应用程序”

Is it possible?可能吗? I need to have a tablet-only-oriented activity with two groups (left one - for files tree, right - for file preview)我需要有两个组的仅面向平板电脑的活动(左一个 - 用于文件树,右 - 用于文件预览)

I already read about "Supporting multiple screens" on android dev.我已经在 android dev 上阅读了有关“支持多个屏幕”的信息。 But they speak about different layouts of same components on different types of screen - I want to add there few "tablet-only" and "phone-only" components...但他们谈到了不同类型屏幕上相同组件的不同布局——我想添加一些“仅限平板电脑”和“仅限手机”的组件......

Or it's a dead-end?或者这是一个死胡同?

It is definitely possible.这绝对是可能的。 I recommend Fragments for this task.我推荐Fragments来完成这个任务。 They were introduced with honeycomb and are exactly for this kind of reusable UI parts you have in mind.它们是与蜂窝一起引入的,并且正是针对您所想到的这种可重用的 UI 部分。 There is also a compatibility lib for lower android versions (I believe down to 1.6.) inside ANDROID-SDK/extras/android/compatibility.在 ANDROID-SDK/extras/android/compatibility 中还有一个用于较低 android 版本(我相信低至 1.6.)的兼容性库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM