Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Hide action bar on initial screen on android

$
0
0

Hi All

I'm facing an issue which several people have faced but no workaround posted by others worked for me.
Have a look here!

image

The issue is obvious, I have no content on the main screen except the action bar. I would like to put my custom content here, and hide the action bar.
Here is the code of my MainActivity

`[Activity(Label = "Tojeero",
Icon = "@drawable/icon",
Theme="@style/Theme.Tojeero",
MainLauncher = true,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation,
ScreenOrientation=ScreenOrientation.Portrait)]
[IntentFilter(new[] { Intent.ActionMain }, Categories = new[] { "android.intent.category.LAUNCHER" })]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);

        //Setup Xamarin forms
        global::Xamarin.Forms.Forms.Init(this, bundle);
        LoadApplication(new FormsApp());

        makeUICustomizations();
    }

    #endregion

    #region Utility Methods

    void makeUICustomizations()
    {
        ActionBar.SetIcon (new ColorDrawable(Resources.GetColor (Android.Resource.Color.Transparent)));
    }

    #endregion
}`

The Theme/Tojeero is my custom theme. In some workarounds I've seen that people set android:windowFullscreen to true and that seems to work for them but not for me. When I set this property, yes activity becomes full screen but the action bar remains there. I believe the issue is in the way Xamarin Forms works. In xamarin forms android everything is fragment. There is always one activity. I believe that the action bar is inside a fragment, and when you set the style of the activity it is not reflected inside its child fragment (this is my opinion not sure if I'm correct or no, please correct me if you know otherwise).

I've also tried to create a custom axml layout for main activity and call SetContentView before other code, but this results that Xamarin Forms stops working, because I believe I just replace all fragment loading logic which is done inside Xamarin Android by my code, and I just see the layout that I've created but the Forms App is not being loaded.

So, I've struggled with this quite a while, and nothing helped. Do you have any ideas how can I customise this first screen? Ideally I would like to should my desired layout on this initial screen. Something like this
image

Any ideas? Thanks


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>