When I add a second activity for android target, it has not TitleBar

RudolfVonKrugsteinRudolfVonKrugstein DEMember ✭✭
edited November 2017 in Xamarin.Forms


Because I want to create a native Android Preference screen in my xamarin forms app, I added a second Activity:

    [Activity(Label = "Unicat OM Settings", Icon = "@drawable/icon", Theme = "@style/MainTheme", ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class SettingsActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
        protected override void OnCreate(Bundle bundle)
            this.Title = "Title";

            // Display the fragment as the main content.
            PrefsFragment prefsFragment = new PrefsFragment();
            this.FragmentManager.BeginTransaction().Replace(global::Android.Resource.Id.Content, prefsFragment).Commit();

The theme @style/MainTheme is set to:

 <style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">

Unfortunately, the activity does not have a Titlebar. As you can see in the code, I tried to add the Titlebar via RequestWindowFeature, but no luck.

How can I add the titlebar?

I just realize, I kind of double post with here: https://forums.xamarin.com/discussion/106180/adding-a-actionbar-to-a-preferenceactivity#latest
Sorry for that.


  • devcatdevcat Member ✭✭


    Not sure why you're not seeing a titlebar, wish I could help with that! Just wanted to say thanks for posting the code snippet. It seems basic, but I had a hard time just getting a simple preference screen to show up in my app, and your code helped out.

  • RudolfVonKrugsteinRudolfVonKrugstein DEMember ✭✭

    @devcat Nice, I am glad that I helped :)

Sign In or Register to comment.