类似Android Market的标签栏

发布于 2024-09-09 22:44:41 字数 199 浏览 3 评论 0原文

实现类似 Android Market 的选项卡栏(应用程序/游戏/下载)的最佳方法是什么?

alt text

如果我可以使用 TabHost 那就太好了,但我相信它不允许这个级别的定制。

What's the best way to implement an Android Market-like tabbar (Apps/Games/Downloads)?

alt text

It would be great if I could use TabHost, but I believe it doesn't allow this level of customization.

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

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

发布评论

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

评论(4

烟雨凡馨 2024-09-16 22:44:41

正如 Cristian 所说,使用 TabHost 绝对是可能的,您甚至不需要使用他链接到的 androidtabs 代码。从 SDK 级别 4(即 Android 1.6)开始,您可以将 View 传递给 TabHost.TabSpec.setIndicator(),这将允许您完全控制选项卡的外观。

但是,点击市场中的任何一个按钮都会打开一个新的 Activity,因此,使用简单的 Button 可能比 TabHost 更能反映该行为。

如果您还需要支持 1.5,您可以从

As Cristian said, it's definitely possible using a TabHost, and you don't even need to use the androidtabs code that he links to. As of SDK level 4 (i.e. Android 1.6) you can pass a View to TabHost.TabSpec.setIndicator(), which will allow you to completely control the look of the tabs.

However, tapping either of those buttons in the Market opens up a new Activity, and as such, using simple Buttons might more closely reflect that behaviour than a TabHost would.

In the event that you need to support 1.5 as well, you could check out the zip archive from this post. It contains TabHost etc. from Android 1.6. Copying this into your project should work, even on Android 1.5. You'll then have setIndicator(View v) available to you.

一花一树开 2024-09-16 22:44:41

可以使用 TabHost 来完成。更好的是,您可以在此处找到有关如何执行此操作的完整功能示例:http://code。 google.com/p/androidtabs/

It's possible to do using TabHost. Even better, you can find a fully functional example of how to do it here: http://code.google.com/p/androidtabs/

听风吹 2024-09-16 22:44:41

让我们试试这段代码:

TabHost.TabSpec spec;  // Reusable TabSpec for each tab
TextView txtTabInfo; // Reusable tab indicator

// Create our tab indicator
txtTabInfo = new TextView(this);
txtTabInfo.setText("videos");
txtTabInfo.setTextSize(16);
txtTabInfo.setTypeface(Typeface.DEFAULT_BOLD);
txtTabInfo.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
txtTabInfo.setBackgroundResource(R.drawable.minitab);
txtTabInfo.setMinHeight(55);

spec = tabHostMM.newTabSpec("video");
spec.setContent(R.id.mm_video);
spec.setIndicator(txtTabInfo);
tabHostMM.addTab(spec);

Let try this code:

TabHost.TabSpec spec;  // Reusable TabSpec for each tab
TextView txtTabInfo; // Reusable tab indicator

// Create our tab indicator
txtTabInfo = new TextView(this);
txtTabInfo.setText("videos");
txtTabInfo.setTextSize(16);
txtTabInfo.setTypeface(Typeface.DEFAULT_BOLD);
txtTabInfo.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
txtTabInfo.setBackgroundResource(R.drawable.minitab);
txtTabInfo.setMinHeight(55);

spec = tabHostMM.newTabSpec("video");
spec.setContent(R.id.mm_video);
spec.setIndicator(txtTabInfo);
tabHostMM.addTab(spec);
_畞蕅 2024-09-16 22:44:41

您可以通过更改 tab.xml 文件来完成此工作。
在线性布局的tab.xml中,首先使用一个子布局,其中包含图像和标签(android market)
在此子布局下方,放置选项卡主机和框架布局。
那么你就可以完成这个任务了。

You can do this job by changing the tab.xml file.
In tab.xml in linear layout, first use one child layout, which contains image and label(android market)
Below this child layout, put tab host and frame layout.
You can achieve this task then.

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