android N中的布局(Layout in android N)

编程入门 行业动态 更新时间:2024-10-28 02:31:51
android N中的布局(Layout in android N)

我有一个关于如何在屏幕上同时安排三个活动的基本问题。

这是我的具体问题 - 根据我从谷歌的Android文档中读到的内容,单个活动一次覆盖整个屏幕。 我想创建三个活动,如下所示


Notification_bar( first activity)
Main section of App (second activity)
Footer section (third activity)

我知道我可以通过使用三个布局实现这一点,它应该没问题。 我出于某种原因要求活动,原因是“主要部分(第二活动)”将用于多个应用程序(例如媒体播放器或是否)。 换句话说,我正在尝试将两个或更多应用程序组合在一起,例如媒体和是否在一个应用程序中,两个应用程序都将拥有它的独立服务线程。

我更喜欢这种设计,因为与app启动器不同,用户可以将已安装的app / apk导入其活动并从启动器活动启动它。 在基于启动器的设计中,它无法控制导入的应用程序进程和活动的生命周期(如果您不这么认为,请更正我)并且我不想选择我对子进程及其活动没有控制权的地方。 此外,它会减慢应用启动/可见时间。

在上面的设计(屏幕上的3个活动)中,主进程可以控制每个活动的生命周期,我可以在主进程中构建一个控制活动生命周期的活动控制器。 当然,每个活动都将在主进程中运行,但将有单独的服务线程来满足其目的。

如果有的话,请随意评论另一种设计策略。 提前感谢您的建议。

I have a basic question on how to arrange three activities on Screen at same time.

Here is my specific question - Based on what I read from Google's android documentation that single Activity covers the entire screen at one time. I want to create three activity like below


Notification_bar( first activity)
Main section of App (second activity)
Footer section (third activity)

I know I can achieve this by using three Layouts and it should be fine. I'm asking for activity for a reason and the reason is that "Main section (second activity)" will be used for several app (e.g. media player or whether) . In other word I'm trying to combine two or more application e.g. media & whether in a single app and both app will have it's separate service thread.

I'm preferring this design because unlike app launcher where user can import the installed app/apk into their activity and launch it from launcher activity. In the launcher based design it does not have control over the life cycle of imported apps process & activity (correct me if you think otherwise) and I do not want to choose where I don't have controls over child process and their activity. Also it slows down the app launch/visible time.

In above design (3 activities on screen) the Main process can control the life cycle of each activity and I can build a activity controller in main process who controls the activity life cycle. Of course each activity will run in main process but will have separate service thread to serve their purpose.

Feel free to comment about another design strategy if you have. Thanks in advance for your suggestion.

最满意答案

您已经确认活动消耗了屏幕。 您应该在活动中使用3个片段。 片段实际上是一个带有额外肉和骨头的视图。 您的活动布局应该有一个LinearLayout作为根,3个Layouts作为子项,它们将作为Fragments的容器。

You already acknowledge that an activity consumes the screen. You should use 3 Fragments inside of your activity. A Fragment is really a View with extra meat and bones. Your activity layout should have a LinearLayout as the root and 3 Layouts as children which will serve to be the containers for the Fragments.

更多推荐

本文发布于:2023-04-28 09:31:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1331377.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:布局   android   Layout

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!