5
\$\begingroup\$

I am developing an app using Libgdx and I don't want the app to go fullscreen and want to show the title bar but the app goes to fullscreen and hides title bar despite all efforts.

Here is my style.xml file

<style name="MyStyle" parent="android:Theme.Light"></style>

Here is AndroidManifest.xml

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/MyStyle" >
    <activity
        android:name="com.mygdx.game.android.AndroidLauncher1"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

Here is AndroidLauncher class

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
    config.hideStatusBar=false;
    initialize(new MyGdxGame(), config);
    setContentView(R.layout.main_activity);
    tv=(TextView)findViewById(R.id.tv);
    tv1=(TextView)findViewById(R.id.tv1);
    button = (Button)findViewById(R.id.button);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (Build.VERSION.SDK_INT < 19) {
                Intent intent = new Intent();
                intent.setType("image/*");
                intent.setAction(Intent.ACTION_GET_CONTENT);
                startActivityForResult(Intent.createChooser(intent, "Select Picture"), SELECT_PICTURE);
            }
            else{
                Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
                intent.addCategory(Intent.CATEGORY_OPENABLE);
                intent.setType("image/*");
                startActivityForResult(Intent.createChooser(intent, "Select Picture"), SELECT_PICTURE);
            }
        }
    });

}

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        if (requestCode == SELECT_PICTURE) {
            Uri selectedImageUri = data.getData();
            selectedImagePath = getPath(selectedImageUri);
            Intent act2 = new Intent(this ,AndriodLauncher2.class);
            act2.setData(selectedImageUri);
            startActivity(act2);
        }
    }
}

public String getPath(Uri uri) {
    String[] projection = { MediaStore.Images.Media.DATA };
    Cursor cursor = managedQuery(uri, projection, null, null, null);
    int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.moveToFirst();
    return cursor.getString(column_index);
}
\$\endgroup\$
1

3 Answers 3

2
\$\begingroup\$

I know this question is old but to make this work here's what I did. Based on this link: http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=12668 provided by @weirdelfb0y

  1. In your AndroidLauncher.java replace the "initialize(new YourGame(), config);" line with:

    RelativeLayout layout = new RelativeLayout(this);

    layout.addView(initializeForView(new YourGame(this), config));

    setContentView(layout);

  2. In your res/values/styles.xml make sure you have the "android:windowFullscreen" set to false and the "android:windowNoTitle" set to true.

That's it!

\$\endgroup\$
0
\$\begingroup\$

LibGDX might override this but try adding this to your style

<item name="android:windowNoTitle">false</item>
<item name="android:windowFullscreen">false</item>
\$\endgroup\$
1
  • \$\begingroup\$ tried this already..but same issue here also \$\endgroup\$
    – ajay
    Jul 13, 2015 at 10:30
0
\$\begingroup\$

Have you tried:

public class MainActivity extends AndroidApplication {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        RelativeLayout layout = new RelativeLayout(this);
        layout.addView(initializeForView(new MainClass(), false));
        setContentView(layout);
    }
}
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .