如何在Android中实现iPhone标题栏
你知道,在 iPhone 中,典型 iPhone 应用程序的四个组件是 标题栏, 导航列表, 目标页面, 和一个按钮栏。
标题栏 标题栏包含以下元素: 返回按钮: 屏幕标题: 命令按钮:
我的问题来了,虽然我可以使用UI框架工具,例如: 电话间隙, 人工授精、 jt查询 开发Web应用程序,但我无法在Android中显示TitleBar效果,
我无法在Android中使用以下代码: meta content="yes" name="apple-mobile-web-app-capable"
实际上,上面的内容可以在 Apple Safari 浏览器中工作,但我无法使用 Safari 来显示我们的 Android 项目,这是我不想要的查看。
有谁知道如何在Android中实现这种效果,请帮助我,非常感谢您的帮助。
到
“不清楚你是开发一个原生的android应用程序还是一个webapp。
– alexanderblom yesterday"
抱歉,我忘了提,我想在Android中开发一个iphone-webapp风格的应用程序。由于太难了,我想使用iWebkit,但似乎仅适用于苹果 iPhone OS 或 Safari,其中包含特定引擎来显示漂亮的布局,如下所示:( -_-!我是新用户,所以我无法在此处发布图像)
(来源:appshopper.com)
You know in iPhone, The four components of a typical iPhone application are
a title bar,
a navigation list,
a destination page,
and a button bar.
for The Title Bar
The title bar includes the following elements:
Back button:
Screen title:
Command button:
My question comes, although i can use UI framework tool, such as:
Phonegap,
iui,
jtquery
to develop web app, but i can't display the TitleBar effect in Android,
i can't use below code in Android:
meta content="yes" name="apple-mobile-web-app-capable"
Actually, the above can work in Apple Safari Browser, but I can't use Safari to display our Android Project, which is i don't want to see.
Does anyone know how to fulfill this effect in Android, please help me, your help will be great appreciated.
to
"It's unclear if you developing a native android application or a webapp.
– alexanderblom yesterday"
sorry that i forget to mention, i want to develop a iphone-webapp-style application in Android. Since it's too difficult, i want to use iWebkit, but it seems only work in apple iPhone OS or Safari which contain the specific engine to display the beautiful layout, like below:( -_-! i am new so i can't post images here)
(source: appshopper.com)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我没记错的话,如果您想以任何方式自定义屏幕顶部的标题栏,您必须做几件事:
首先,阅读 这个关于标题栏自定义的帖子,因为它非常详细。
然后,您必须向其中添加更多内容以满足您的要求,所有这些都在同一个 xml 文件中,该文件将成为您的 titlebar.xml:
-a button, on您为哪个侦听器分配与每个 Android 手机的正常后退键相同的 keyEvent。
-a textview 表示您想要放入的任何标题。
-a button 表示命令按钮,无论它在 Iphone 中做什么(如果你告诉我它的作用,也许我将能够提供更多详细信息)
然后,据我所知,您希望在所有页面上都可以使用它,而不必在每个活动上请求标题栏自定义,我建议您使用与我相同的技巧:定义一个超类,您的所有活动都将扩展它。
然后你在这个类中请求windowfeatures,并在这个类中进行所有的自定义。最后,你只需在所有子类的oncreate中调用标题栏textview的变量来在每个页面上分配你想要的字符串。如果您的字符串是动态生成的,比如说您在后台线程中从 internetv 加载的文件名,则您将需要为主线程定义一个处理程序,因为您无法从具有该属性的线程之外的另一个线程更新视图创建了它。
希望有帮助。如果您对此有任何疑问,请随时询问,我会密切关注您的主题,因为我很难让我的标题栏正常工作。
祝你好运
If I'm not mistaken, if you want to custom in any way the title bar at the top of your screen, you have to do several things :
First, read this thread about titlebar customisation, as it's quite detailled.
Then, you have to add a few more things to it to match your requirements, all in the same xml file which will be your titlebar.xml:
-a button, on which listener you assign the same keyEvent as the normal back key of every android phone.
-a textview for whatever title you want to put in.
-a button for the command button, for whatever it does in Iphone (if you tell me what it does, maybe i'll be able to give more details)
Then, as I take it, you want to have it available on all your pages, without having to request titlebar customization on every activity, I would recommend you to use the same trick as I did : Define a superclass, which all your activities will extend.
then you you requestwindowfeatures in this class, and do all your customization in this one.Finnaly, You just have to call the variable of your titlebar textview in the oncreate of all your subclasses to assign the string you want on each page. If your string is generated dynamically from, lets say a file name you load from the internetv in a background thread, you will need to define a handler to the main thread as you can't update a view from another thread than the one that has created it.
Hopes that helps. If you have any question about that, feel free to ask, i'll keep an eye on your topic, because I had quite a pain to make my titlebar work properly.
good luck