protected override void OnAttached() { try { var textView = this.Control as TextView; if (textView == null) { return; } if (AutoFitFontSizeEffectParameters.GetMinFontSize(this.Element) == NamedSize.Default && AutoFitFontSizeEffectParameters.GetMaxFontSize(this.Element) == NamedSize.Default) { return; } var min = (int)AutoFitFontSizeEffectParameters.MinFontSizeNumeric(this.Element); var max = (int)AutoFitFontSizeEffectParameters.MaxFontSizeNumeric(this.Element); if (max <= min) { return; } TextViewCompat.SetAutoSizeTextTypeWithDefaults(textView, TextViewCompat.AutoSizeTextTypeNone); //textView.SetAutoSizeTextTypeUniformWithConfiguration(min, max, 1, (int)ComplexUnitType.Sp); //text.SetAutoSizeTextTypeUniformWithConfiguration(min, max, 1, (int)ComplexUnitType.Sp); } catch (Exception e) { } //if (this.Control is AppCompatTextView textView) //{ // if (AutoFitFontSizeEffectParameters.GetMinFontSize(this.Element) == NamedSize.Default && // AutoFitFontSizeEffectParameters.GetMaxFontSize(this.Element) == NamedSize.Default) // return; // var min = (int)AutoFitFontSizeEffectParameters.MinFontSizeNumeric(this.Element); // var max = (int)AutoFitFontSizeEffectParameters.MaxFontSizeNumeric(this.Element); // if (max <= min) // return; // //if (Build.VERSION.SdkInt >= BuildVersionCodes.O) // //{ // textView.SetAutoSizeTextTypeUniformWithConfiguration(min, max, 1, (int)ComplexUnitType.Sp); // //} // //else // //{ // //} //} }
protected override void OnAttached() { if (this.Control is TextView textView) { if (AutoFitFontSizeEffectParameters.GetMinFontSize(this.Element) == NamedSize.Default && AutoFitFontSizeEffectParameters.GetMaxFontSize(this.Element) == NamedSize.Default) { return; } var min = (int)AutoFitFontSizeEffectParameters.MinFontSizeNumeric(this.Element); var max = (int)AutoFitFontSizeEffectParameters.MaxFontSizeNumeric(this.Element); if (max <= min) { return; } textView.SetAutoSizeTextTypeUniformWithConfiguration(min, max, 1, (int)ComplexUnitType.Sp); } }
protected override void OnAttached() { if (this.Control is UILabel label) { if (AutoFitFontSizeEffectParameters.GetMinFontSize(this.Element) == NamedSize.Default && AutoFitFontSizeEffectParameters.GetMaxFontSize(this.Element) == NamedSize.Default) { return; } var min = (int)AutoFitFontSizeEffectParameters.MinFontSizeNumeric(this.Element); var max = (int)AutoFitFontSizeEffectParameters.MaxFontSizeNumeric(this.Element); if (max <= min) { return; } label.AdjustsFontSizeToFitWidth = true; label.MinimumFontSize = (float)min; label.Font = label.Font.WithSize((float)max); } }