我有以下布局.
当我在MainActivity类中创建WebView和GestureOverlayView对象时,它会返回null两个对象.
GestureOverlayView gesturesView = (GestureOverlayView) findViewById(R.id.gestures);
WebView webView = (WebView) findViewById(R.id.webview);
Run Code Online (Sandbox Code Playgroud)
我的布局:
<?xml version="1.0" encoding="utf-8"?>
<android.gesture.GestureOverlayView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gestures"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
</android.gesture.GestureOverlayView>
Run Code Online (Sandbox Code Playgroud)
当我将上面的布局更改为以下(我移动android.gesture.GestureOverlayView到里面LinearLayout),它工作正常.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<android.gesture.GestureOverlayView
android:id="@+id/gestures"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</android.gesture.GestureOverlayView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚我以前的布局有什么问题.
请有人解释一下.
| 归档时间: |
|
| 查看次数: |
1698 次 |
| 最近记录: |