문제

Im trying to remove the titlebar at the top of my app.

I know this can be done by adding, @android:style/Theme.NoTitleBar to the manifest. The thing is that this makes the Holo theme disappear on 3.0+ devices. Are there anyway I can remove the titlebar and keep the orginal theme?

-EDIT- Unforiunally this line @android:style/Theme.Holo.NoActionBar requires api level above 11.

도움이 되었습니까?

해결책

You can specify different default themes for different API levels.

In Android you have the directories values-v11 and values. The first one is for all Android 3.0 and above (if no other one with higher version is specified). The second is the default one.

In the styles.xml of values-v11 you define:

<style name="AppBaseTheme" parent="android:Theme.Holo.NoActionBar"></style>

and in the styles.xml of values:

<style name="AppBaseTheme" parent="android:Theme.NoTitleBar"></style>

If you put android:theme="@style/AppBaseTheme" in the <application> tag of the manifest you should keep the Holo theme on 3.0+ devices.

다른 팁

You can try this:-

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

requestWindowFeature(Window.FEATURE_NO_TITLE);
...

}

use bellow method before write setContentView()

 @Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
}

Use below code in onCreate()

if(android.os.Build.VERSION.SDK_INT>11)
    setTheme(android.R.style.Theme.Holo.NoActionBar);
else
    setTheme(android.R.style.Theme_DeviceDefault_NoActionBar);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top