带有原生控件的 Android PhoneGap [英] Android PhoneGap with Native Controls
问题描述
我正在尝试使用 PhoneGap 构建一个 Android 应用程序.
I am trying to build an Android application with PhoneGap.
我需要能够使用 PhoneGap WebView (super.appView) 及其所有 javascript 魔法,但我还需要在 WebView 周围显示一些本机 UI 控件.
I need to be able to use the PhoneGap WebView (super.appView) and all of its javascript magic but I also need to display some native UI controls around the WebView.
这篇文章部分地提供了一个解决方案 Android PhoneGap 插件,UI 标签栏, 调整 WebView 的大小
This post goes part way to providing a solution Android PhoneGap Plugin, UI tabbar, resize WebView
有没有人设法用原生 UI 实现 PhoneGap?
Has anyone managed to implement PhoneGap with a native UI?
我也将使用 GestureOverlayView 但那是另一回事了 ;)
I will also be using a GestureOverlayView but thats another story ;)
推荐答案
答案:
super.onCreate(savedInstanceState);
//creates super.appView and calls setContentView(root) in DroidGap.java
init();
//just an empty LinearLayout
layoutId = R.layout.blank;
view = new LinearLayout(this);
setContentView(layoutId);
view.addView(your_component_here);
view.addView((View) appView.getParent()); //adds the PhoneGap browser at index 1
//accesses the browser at index 1. Tells browser to not fill view
view.getChildAt(1).setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1));
setContentView(view);
我很难告诉你这是如何工作的,我只能告诉你它确实如此,而且都是我自己的工作.
I would struggle to tell you how this works, all I can tell you is that it does and it is all my own work.
将视图设置为不同的颜色也可以帮助您了解正在发生的事情......
Setting the view to a different colour can help you to see what is going on too....
view.setBackgroundColor(Color.BLUE);
使用 PhoneGap-1.0.0.jar 迄今为止的最新版本.
Working with PhoneGap-1.0.0.jar the latest release so far.
这篇关于带有原生控件的 Android PhoneGap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!