Why does the designer always switch back to the default theme and is there an option to prevent it?

Hi,

we are developing a pixelperfect xamarin.android app for just one specific android device that will run in fullscreen with no title bar. Working with the designer is a hassle because no matter how often i switch the theme to Black NoTitlebar Fullscreen, it will always switch back to Default Theme every few changes which makes it very difficult to preview and arrange stuff on the layouts.
Is there an option to prevent the switching?

Cheers

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai

    Set Theme to 'Theme.Holo.Light.NoActionBar.Fullscreen' and change AppCompatActivity to Activity.

    [Activity(Label = "@string/app_name", Theme = "@android:style/Theme.Holo.Light.NoActionBar.Fullscreen", MainLauncher = true)]
    public class MainActivity : Activity
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);
        }
    }
    

  • JarvanJarvan Member, Xamarin Team Xamurai

    Or you can set in style.xml like:

    <style name="AppTheme" parent="Theme.AppCompat.Light">
      <item name="windowNoTitle">true</item>
      <item name="windowActionBar">false</item>
      <item name="android:windowFullscreen">true</item>
    </style>
    
    [Activity(Label = "@string/app_name", Theme = "@style/AppTheme", MainLauncher = true)]
    public class MainActivity : AppCompatActivity
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);
        }
    }
    

    It works for both Activity and AppCompatActivity.

  • syslord2k2syslord2k2 Member ✭✭

    Thanks but i know how to change the theme of the app on the device, i just want that to be reflected in the designer, but the designer switches back to Default Theme all the time which has the action bar and soft buttons.

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited June 25

    i just want that to be reflected in the designer, but the designer switches back to Default Theme all the time which has the action bar and soft buttons.

    Sorry, could you share more details?

  • syslord2k2syslord2k2 Member ✭✭

    This is how it looks in the designer
    https: //us.v-cdn.net/5019960/uploads/editor/wg/gn19vfsl775x.png

    This is how i want it to look but everytime i switch it it to fullscreen it switches back by itself to default whenever i make a change
    https: //us.v-cdn.net/5019960/uploads/editor/nv/7yan646pkbyy.png

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited June 25

    This is the previewer, you can view the different styles by changing the theme/version. But it has nothing to do with the code. The view of the Activity is determined by the code when debugging.

  • syslord2k2syslord2k2 Member ✭✭

    I am only talking about the previewer, i just want it to keep the Theme that i choose but it keeps changing back to the default theme every few changes. I have the right theme on the device, there is no problem within the app. It's just the previewer that i want to keep on the theme!!!!

  • JarvanJarvan Member, Xamarin Team Xamurai

    I tried to reproduce the issue on VS. But it works well when changing the code of xaml. Have you changed some settings? What's the version of your VS?

Sign In or Register to comment.