Android:活动主持人?

发布于 2024-12-17 11:35:53 字数 441 浏览 2 评论 0原文

我有一个基本问题,但谷歌没有为我提供很多结果(无论如何不是英语的)。基本上我想做的就是这样:

我有一个图形需要用作整个应用程序的持久标题,如下所示:即使它只是返回到新视图中,我也无法让它在新意图调用时从屏幕上滑落,客户会抱怨硬核,因为这个应用程序的 iPhone 版本不这样做。

所以基本上我正在考虑类似 TabHost 如何工作但没有选项卡的东西。有没有办法创建一个新的布局文件作为主布局文件加载,其中包含 LinearLayout,将图形放在顶部,然后将“意图”或“活动”嵌套在布局文件中的另一个元素中?

谷歌可能没有给我任何结果,因为我可能在这里使用了错误的术语,但对此事的任何帮助都将是令人难以置信的!

谢谢!

编辑:

很抱歉我应该提到这需要与 2.3.3 (Gingerbread) 兼容。我听说过“Fragments”并且我看到它们在 ADK3 中被引入了:(

I have a basic problem but Google is not yielding many results for me (well not english ones anyways). Basically all I want to do is this:

I have a graphic I need to use as a persistent header across the App, as in: I cant have it slide off the screen on new intent calls even if it just comes back in the new view, the client will complain hardcore because the iPhone version of this App doesn't do that.

So basically I'm thinking of something like how TabHost works but without tabs. Is there a way to create a new Layout File to be loaded as the main with a LinearLayout in it, have the graphic up top, and then nest an "intent" or "activity" in another element in the layout file?

Google probably isn't yielding me any results because I'm probably using the wrong terminology here, but any help on this matter would be incredible!

Thanks!

EDIT:

I'm sorry i should mention that this needs to be 2.3.3 (Gingerbread) compatible. I'm hearing about "Fragments" and I see they got introduced in ADK3 :(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

隱形的亼 2024-12-24 11:35:53

Framgent 或 Fragment 兼容包将适合您。甚至不需要在谷歌上搜索,因为 ApiDemoes 的片段示例就足以了解想法。

Main Activity 应该有 1 个 Header View 和 1 个 Fragment Placeholder 。然后在这个占位符中推送、弹出片段。

另一种让我印象深刻的方法是:

创建一个带有 1 个选项卡的 TabWidget 。它的视图将是静态 header 并向 content 添加一个活动组。现在屏幕的移动部分将是 ActivityGroup 的子级。

Framgent or Fragment compatiblibity package will work for you . even no need to search on google because Fragment Example of ApiDemoes will be enough to get idea .

Main Activity should have 1 Header View and one Fragment Placeholder . then push, pop fragments in this place holder .

One more Way hitting to my head is :

Create a TabWidget with 1 tab . its view will be static header and add an activity group to content . now moving portion fo screen will be child of an ActivityGroup .

倒带 2024-12-24 11:35:53

覆盖您的活动的 windowBackground 属性可能对您有用。基本上,您创建一个样式(通常在 res/values/themes.xml 文件中),如下所示:

<style name="WithPersistentHeader" parent="@android:style/Theme">
    <item name="android:windowBackground">@drawable/persistent_header</item>
</style>

然后您可以将该样式应用于整个 或AndroidManifest.xml 中的每个 基础:

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/WithPersistentHeader" >

    <!-- activities and services ... -->

</application>

每个 Activity 布局都需要腾出标头所在的空间,以便可以从下面有窗户。

关于此的文档不​​多,但有一篇开发人员博客文章这里包含一些相关详细信息。

Overriding the windowBackground attribute for your activities might work for you. Basically you create a style (usually in a res/values/themes.xml file) like this:

<style name="WithPersistentHeader" parent="@android:style/Theme">
    <item name="android:windowBackground">@drawable/persistent_header</item>
</style>

You can then apply the style to your whole <application> or on a per <activity> basis in AndroidManifest.xml:

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/WithPersistentHeader" >

    <!-- activities and services ... -->

</application>

Each of your activity layout will then need to vacant the space where the header is located so it can show through from the window underneath.

There's not much documentation about this, but there's an Developers blog post here with some relevant details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文