Android:如何在 native Activity 之上添加另一个 View

标签 android user-interface java-native-interface android-ndk

我是 NDK 新手,正在使用 3D 引擎 -Ogre 编写游戏。我在 list 中有这样的东西指向我的 native 库:

 <activity
        android:name="android.app.NativeActivity"
         android:screenOrientation="landscape"
          android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
         <!-- Tell NativeActivity the name of or .so -->
        <meta-data android:name="android.app.lib_name" android:value="OgreAndroidTemplate" />

然后我通过从另一个 java Activity 调用此 Activity 来启动此 Activity:

Intent engineIntent = new Intent( _context, NativeActivity.class);
            startActivity(engineIntent);

但是,我希望在我的游戏之上进行一些 UI 处理(例如菜单按钮或广告),并希望在 java 端处理它。有什么方法可以在我的游戏之上添加另一个 View 或 Activity 吗?

提前非常感谢。

最佳答案

不确定 NDK,但如果您使用普通的 Android XML 布局,则可以使用 FrameLayout

<FrameLayout>
   <YourNdkView/>
   <LinearLayout>
      <!-- buttons etc -->
   </LinearLayout>
</FrameLayout>

关于Android:如何在 native Activity 之上添加另一个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11539532/

相关文章:

Android 从适配器自定义类调用 findViewById

java - 将字符串数组更改为列表<String> - Java/Android

css - 需要自定义轮播帮助

user-interface - 用偶数设置 IntProperty 的代码

Android NDK 在调用 getSystemService 的 CallObjectMethod 中崩溃

Java创建.dll文件

安卓 : Draw Circle With Text Inside

android - 如何在另一个模块的androidTest目录中使用代码

javascript - 应用阴影的最佳方式是什么?

android - 将 minizip 与 android ndk 一起使用