Edd*_*Edd 5 layout android webview cordova
我正在尝试使用PhoneGap构建一个Android应用程序.
我需要能够使用PhoneGap WebView(super.appView)及其所有javascript魔术,但我还需要在WebView周围显示一些本机UI控件.
这篇文章部分提供Android PhoneGap插件,UI标签栏,调整WebView的解决方案
有没有人设法使用原生UI实现PhoneGap?
我也将使用GestureOverlayView,但这是另一个故事;)
Edd*_*Edd 12
回答:
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);
Run Code Online (Sandbox Code Playgroud)
我很难告诉你它是如何工作的,我只能说它确实如此,这都是我自己的工作.
将视图设置为不同的颜色可以帮助您查看正在发生的事情....
view.setBackgroundColor(Color.BLUE);
Run Code Online (Sandbox Code Playgroud)
使用PhoneGap-1.0.0.jar到目前为止的最新版本.
一种更清洁的方法:
super.onCreate(savedInstanceState);
// Create native view with UI controls.
View header = View.inflate(getContext(), R.layout.header, null);
// PhoneGaps WebView is located inside a LinearLayout.
// The protected (and therefore inherited) variable root
// references this LinearLayout. Add your native Views
// to this variable.
root.addView(header);
// Create WebView and add it automatically to the LinearLayout.
super.loadUrl("file:///android_asset/www/index.html");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10974 次 |
| 最近记录: |