我能得到的Andr​​oid浏览叠加的libgdx GL表面的顶部? [英] Can I have Android Views overlayed on top of the libgdx GL surface?

查看:155
本文介绍了我能得到的Andr​​oid浏览叠加的libgdx GL表面的顶部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想上显示,在libgdx的OpenGL的表面发生的一切之上的一些自定义视图(如TextViews阿拉伯语/亚洲文本)(小于 - 我认为这是一个表面观)。这可能吗?怎么样?

I would like to display some custom views ( e.g. TextViews with Arabic/Asian text) on top of everything that happens in libgdx's OpenGL Surface (<--I assume it's a surface view). Is this possible? How?

的动机是,我有一个良好的分量在我现有的code显示文本,我想用这个来保持。

The motivation is that I have a proven component for displaying text in my existing code and I would like to keep using this.

我已经使用其他GLSurfaceViews用前先查看层次。只是想知道如何/如果这可以在libgdx完成。性能并不重要,所有多,因为游戏中libgdx是一个简单的益智游戏,并且当显示的文本的意见,本场比赛是pretty多暂停。

I have used other GLSurfaceViews with View hierarchies before. Just wondering how/if this can be done in libgdx. Performance doesn't matter all to much because the "game" in libgdx is a simple puzzle game, and when the text views are shown, the game is pretty much paused.

推荐答案

当然可以!在Libgdx使用AdMob这官方指南拥有所有你需要帮助你显示自定义视图。虽然它的重点是整合AdMob广告,则可以使用的机制来创建和显示对OpenGL的表面的俯视图。例如,这是你如何对你的Andr​​oid游戏的表面观的顶部显示一个文本视图:

Yes you can! This official guide on using Admob in Libgdx has all you need help you display custom views. Though it focuses on integrating Admob ads, you can use the mechanism to create and display views on top of the OpenGL Surface. For example this is how you'd display a text view on top of your android game's surface view:

   @Override public void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Create the layout
        RelativeLayout layout = new RelativeLayout(this);

        // Do the stuff that initialize() would do for you
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

        // Create the libgdx View
        View gameView = initializeForView(new HelloWorld(this), false);

        // Create and setup the TextView
        TextView helloText = new TextView(this); 

        // Add the libgdx view
        layout.addView(gameView);

        // Add the TextView
        RelativeLayout.LayoutParams textViewParams = 
            new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, 
                    RelativeLayout.LayoutParams.WRAP_CONTENT);
        textViewParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
        textViewParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

        layout.addView(helloText, textViewParams);

        // Hook it all up
        setContentView(layout);
    }

这篇关于我能得到的Andr​​oid浏览叠加的libgdx GL表面的顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆