logo
down
shadow

Going crazy trying to change android theme on Xamarin.Forms


Going crazy trying to change android theme on Xamarin.Forms

By : Ubachef
Date : October 20 2020, 08:10 PM
I think the issue was by ths following , Create Android renderer for view cell and override GetCellCore method. Sample code below:
code :
public class CustomViewCellRenderer:ViewCellRenderer
{
    public CustomViewCellRenderer()
    {
    }

    protected override Android.Views.View GetCellCore(Cell item, Android.Views.View convertView, ViewGroup parent, Android.Content.Context context)
    {
         var cell= base.GetCellCore(item, convertView, parent, context);
        if (parent is Android.Widget.ListView listView)
        {
            listView.SetSelector(Android.Resource.Color.Transparent);
            listView.CacheColorHint = Android.Graphics.Color.Transparent;

        }
        return cell;
    }

    protected override void OnCellPropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        base.OnCellPropertyChanged(sender, e);
    }
}


Share : facebook icon twitter icon
Changing the default dark Android theme to white in Xamarin.Forms?

Changing the default dark Android theme to white in Xamarin.Forms?


By : A. Jeff
Date : March 29 2020, 07:55 AM
it helps some times You can put Theme parameter to ApplicationAttribute of your main activity
like this
code :
[assembly: Application(Icon = "@drawable/Icon", Theme = "@android:style/Theme.Holo.Light")]
<application android:theme="@android:style/Theme.Holo.Light" />
Xamarin Forms Android startup issue with AppCompat Theme note

Xamarin Forms Android startup issue with AppCompat Theme note


By : Myungwon Min
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further The issue was really quite strange and I am not fully sure what of the things exactly did help, but what I done was:
removing obj/bin folders; "Clean Solution" option; restarting Visual Studio.
xamarin - Android change theme programmatically

xamarin - Android change theme programmatically


By : Tiffany Hereth Adamo
Date : March 29 2020, 07:55 AM
I wish this helpful for you To call a method in your MainActivity from the net standard project, you need to pass a reference to your MainActivity to the standard project. The best way to do this is to pass a reference to the shared net standard project App constructor, which is invoked from MainActivity. Of course, you cannot declare a parameter in your App constructor of type MainActivity, because your net standard project cannot reference the Android project, and because, if you will in the future implement iOS and / or UWP version of your app, you need a common type between all these different project.
So, you have to define an interface in your net standard project:
code :
public interface IThemeChanger
    {
        void ApplyTheme(string newTheme);
    }
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity, IThemeChanger
    {
        public void ApplyTheme(string newTheme)
        {
            if (newTheme?.ToLower() == "dark")
            {
                SetTheme(Resource.Style.Base_Theme_AppCompat);
            }
            else
            {
                SetTheme(Resource.Style.Base_Theme_AppCompat_Light);
            }
        }
protected override void OnCreate(Bundle savedInstanceState)
    {
        TabLayoutResource = Resource.Layout.Tabbar;
        ToolbarResource = Resource.Layout.Toolbar;

        base.OnCreate(savedInstanceState);
        global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
        LoadApplication(new App(this));
    }
    public readonly IThemeChanger ThemeChanger;
    public App(IThemeChanger themeChanger)
    {
        InitializeComponent();
        this.ThemeChanger = themeChanger;
        MainPage = new MainPage();
    }
((App.Current) as App).ThemeChanger.ApplyTheme("Dark");
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity, IThemeChanger
{
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);

            var container = IoC.Get<SimpleContainer>();
            if (container.HasHandler<IThemeChanger>())
            {
                container.UnregisterHandler<IThemeChanger>();
            }
            container.Instance<IThemeChanger>(this);

            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
            LoadApplication(container.GetInstance<App>());
        }
public class LoginViewmModel{
    private readonly IThemeChanger themeChanger;

    public LoginViewModel(IThemeChanger themeChanger){
        this.themeChanger = themChanger;
    }

    private void ApplyTheme{
        themeChanger.ApplyTheme("Dark");
    }
}
How do I to change the Android Theme of a Xamarin project?

How do I to change the Android Theme of a Xamarin project?


By : user2700419
Date : March 29 2020, 07:55 AM
To fix this issue Change the Java inheritance from AppCompatActivity to Activity, then you will solve this issue.
Please take a look the following thread for detailed info:
Xamarin Android, Xamarin Forms orientation change

Xamarin Android, Xamarin Forms orientation change


By : mickivargas
Date : March 29 2020, 07:55 AM
Does that help Xamarin Android app that use the Xamarin Forms UI framework. I detect the screen orientation and want to only allow portrait and landscape for a specific Page but portrait only for all other pages. , Have a static property in your App.Xaml.cs
Related Posts Related Posts :
  • How to employ keyed-hash message authentication code (HMAC) with Android Keystore
  • Prevent inviting existing users or previously invited
  • How to overwrite windowSoftInputMode using edit-config tag in cordova
  • Difference between Loader and AsyncTask
  • In Firebase Android, retrieve the value of a child node and save it in a boolean variable
  • when i scroll the custom list in my android app then the favorite icon which is part of the custom adapter changes on it
  • adding room dependency gives manifest merge error
  • Visibility of RelativeLayout change on scrolling Gridview
  • Strange LiveData behavior vs ObservableField
  • Which layout is used for clash of clans home screen? We can scroll it horizontal as well as vertical. Please illuminate
  • RxJava: Know when observable is finished and return Boolean Observable to the caller
  • how to use savedInstanceState to save camera information when the orientation change occure
  • Style React-Native via Styles.xml
  • Keyboard won't show after calling InputMethodManager.showSoftInput
  • Compiling ffmpeg for Android on OSX
  • Button does not get clicked on the first attempt
  • AR Core performance, learning curve and comparison with other frameworks
  • Codename one : Attaching images to email message fails
  • Error: Unsupported type 'viewItem' in Android build
  • setLayoutParams on ConstraintLayout does not change size
  • How to profile the fetch time of the android gradle libraries
  • Kotlin setOnclickListener
  • Naming convention for methods returning RxJava's Completable
  • Conv3D not working
  • FFmpeg audio video merge command
  • Do you have to use gradle-experimental for JNI?
  • How to get key hashes for facebook for facebook app?
  • ZXing not calling onActivityResult, When scanning QR Code
  • Integration of Android Native module with existing Xamarin Native Project
  • Restore RecyclerView state after rotating
  • ViewModelProviders java.lang.RuntimeException trying to instantiate class which inherit AndroidViewModel
  • SKD19 vs SDK24 - Usage of API documented as @since 1.8+
  • filter option in list view fragment activity
  • Picture from camera not showing up in second activity
  • How to change imageview according to screen size
  • How to copy Android Studio project to remote Git (NOT GitHub) server
  • How to get React-Native to announce specific accessibility message via AccessibiliyManager?
  • Change colors of com.tech.freak.wizardpager.ui.StepPagerStrip
  • Android fullscreen activity shows ActionBar
  • Turn on the screen when timer calls onFinish()
  • Would like a bit of clarification with SQLite database's onUpgrade method
  • Use ObjectBox with Libgdx
  • How to make combine Gregorian and Hijri calendar in Android?
  • Try to read text file from sdcard in other language
  • "App not installed" message when installed apk
  • How to execute a designated test suite class in Firebase Test Lab
  • play music with background service
  • background not visible on LG G3
  • should every View have an id?
  • Realm object server sync on low connection.
  • Correct way to add more views to adapter
  • Getting error in android support library
  • Instant app zip uploading error
  • "No emulator installed" error in Android Studio even though Intel HAXM is up and running
  • AsyncTask without leaks
  • SQLiteException : No such table found whereas a table was created
  • Using @Component.Builder with constructor params
  • No injector was found for fragment dagger 2.11
  • Android Volley Https SSL self signed and Google Maps API
  • Why does the onClickListener not work anymore in this example?
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org