MrMee
MrMee

Reputation: 153

Android, Xamarin: How does <Styles> translate to C#?

I am working on an app in Visual Studio with the appcompat theme. I want to put it into fullscreen mode. This however isn't working since I cannot find the "Styles" section mentioned for instance here:

Full Screen Theme for AppCompat

Does anyone know how to translate that into C#? Or even better, how to put the appcompat into fullscreen? :)

THANKS :)

Upvotes: 0

Views: 57

Answers (1)

pinedax
pinedax

Reputation: 9346

The styles.xml is not created with the default template but you can manually created.

In the Solution go to Resources -> Values and right click over this last one and select Add -> New File.

From the dialog select XML and put the name of styles.xml

enter image description here

Once created pastes this inside

<?xml version="1.0" encoding="UTF-8" ?>
<resources>
    <style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="Theme.AppCompat.Light">
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="android:windowFullscreen">true</item>
        <item name="android:windowContentOverlay">@null</item>
    </style>
</resources>

We are almost done. Now you just have to tell the app to use this Theme you just created.

If you want the whole App to be full screen you need to set the Theme on the Application Layer. This can be done in the project options -> Android Application, in the Application Theme section paste the name of theme you want to use.

enter image description here

Notice the full name is

@style/Theme.AppCompat.Light.NoActionBar.FullScreen

You are good to go! Your whole app will now run full screen.

Hope this helps.-

Upvotes: 2

Related Questions