Google Play游戏服务和LibGDX如何集成而不显示标题栏?

4

使用此代码成功连接:

向LibGDX添加Google Play服务的教程

然而,现在我有了Android标题栏。我已经尝试确定到底是什么导致标题栏显示(并且正在使用教程中的代码),但我认为是在混合中具有MainActivity构造函数,这会绕过请求noTitle的LibGDX调用。

因此,我接下来尝试在我的清单中添加NoTitleBar的主题功能,这样可以解决问题,但是不知何故,现在发生了方向更改(这不是清单中所说的)。

有谁能看到我需要在我的主项目或Android项目中执行以下操作:

1)没有标题栏 2)不允许方向更改 3)具有Google Play服务的连接

这是清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pgs.libgdx.liars.dice"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="17" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >

    <meta-data android:name="com.google.android.gms.games.APP_ID"
        android:value="@string/app_id" />

    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        android:screenOrientation="landscape"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>

以下是 Android 项目中的相关代码:

public class MainActivity extends AndroidApplication implements GameHelperListener, GoogleInterface {

private GameHelper aHelper;

private OnLeaderboardScoresLoadedListener theLeaderboardListener;

public MainActivity(){
    aHelper = new GameHelper(this);
    aHelper.enableDebugLog(true, "MYTAG");

    //create a listener for getting raw data back from leaderboard
    theLeaderboardListener = new OnLeaderboardScoresLoadedListener() {

        public void onLeaderboardScoresLoaded(int arg0, LeaderboardBuffer arg1,
                LeaderboardScoreBuffer arg2) {

            System.out.println("In call back");

            for(int i = 0; i < arg2.getCount(); i++){
                System.out.println(arg2.get(i).getScoreHolderDisplayName() + " : " + arg2.get(i).getDisplayScore());
            }
        }
    };
}

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

    AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
    cfg.useGL20 = false;
    aHelper.setup(this);
    initialize(new LiarsDiceGame(this), cfg);
}

而且相关的主要代码:

public LiarsDiceGame(){

}

public LiarsDiceGame(GoogleInterface anInterface ) {
    platformInterface = anInterface;
    //platformInterface.Login();
}

@Override
public void create() {      
    float w = Gdx.graphics.getWidth();
    float h = Gdx.graphics.getHeight();

    camera = new OrthographicCamera(1, h/w);
    batch = new SpriteBatch();

    texture = new Texture(Gdx.files.internal("data/libgdx.png"));
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    TextureRegion region = new TextureRegion(texture, 0, 0, 512, 275);

    sprite = new Sprite(region);
    sprite.setSize(0.9f, 0.9f * sprite.getHeight() / sprite.getWidth());
    sprite.setOrigin(sprite.getWidth()/2, sprite.getHeight()/2);
    sprite.setPosition(-sprite.getWidth()/2, -sprite.getHeight()/2);
}

除此之外,使用gdx-setup-ui.jar设置LibGDX项目的过程与以往完全相同。


在查看logcat时,我确实看到它提到了“内容已经显示,无法请求FEATURE_NOTITLE。”我尝试查看后端,但无法看到为什么会出现这种情况。除非(我认为)由于对MainActivity的调用,Manifest被Android使用,但为什么方向不会被锁定呢? - user2346305
1个回答

4

您的清单文件语法存在问题,在此行中:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >

该行末尾的尖括号不应存在。

哎呀...在Eclipse中我什么也看不到(无论如何都没有报错)。现在像冠军一样运转! - user2346305

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接