You cannot combine custom title with other title features

前端 未结 2 1290
攒了一身酷
攒了一身酷 2021-01-06 10:42

In my application, I\'m using ActionBarSherlock library. Also I\'m using a custom title bar. Here goes my onCreate:

requestWindowFeature(Window.FEATURE_CUSTO         


        
2条回答
  •  隐瞒了意图╮
    2021-01-06 11:13

    I had the same problem and solved it:

    THE ROOT CAUSE: In the Manifest, I copy pasted this tag by mistake from my splash screen into my activity: @android:style/Theme.NoTitleBar The fatal exception occured when I also requested a FEATURE_CUSTOM_TITLE on my activity, causing the conflict.

    SOLUTION: To fix it, I checked these 3 things: 1)OnCreate method:

    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
            setContentView(R.layout.activity_login);
            getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_titlebar);
    
        }
    

    2)INSIDE your manifest.xml: Make sure a line such as these ONLY appears in a splash screen if you have one: android:theme="@android:style/Theme.NoTitleBar REMOVE that line from any other activity if you want a custom Bar.

    In the application tag , my only theme tag is this one: android:theme="@style/AppTheme"

    In the activity tag, I have no theme tag.

    3) Go to your activity's XML layout, and view it in GRAPHIC LAYOUT mode. Maye sure your that the Theme says AppTheme (its the the you put on the manifest) Mine said "No Title", so this was causing the problem.

提交回复
热议问题