зеркало из https://github.com/DeGsoft/maui-linux.git
Use TextViewCompat to so API <23 handle setTextAppearance correctly (#910)
This commit is contained in:
Родитель
c37629a9ca
Коммит
b934308f62
|
@ -10,6 +10,7 @@ using AView = Android.Views.View;
|
|||
using AColor = Android.Graphics.Color;
|
||||
using AColorDraw = Android.Graphics.Drawables.ColorDrawable;
|
||||
using Xamarin.Forms.Internals;
|
||||
using Android.Support.V4.Widget;
|
||||
|
||||
namespace Xamarin.Forms.Platform.Android
|
||||
{
|
||||
|
@ -57,7 +58,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
_mainText.SetSingleLine(true);
|
||||
_mainText.Ellipsize = TextUtils.TruncateAt.End;
|
||||
_mainText.SetPadding((int)context.ToPixels(15), padding, padding, padding);
|
||||
_mainText.SetTextAppearanceCompat(context, global::Android.Resource.Style.TextAppearanceSmall);
|
||||
TextViewCompat.SetTextAppearance(_mainText, global::Android.Resource.Style.TextAppearanceSmall);
|
||||
|
||||
using (var lp = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent))
|
||||
textLayout.AddView(_mainText, lp);
|
||||
|
@ -67,7 +68,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
_detailText.Ellipsize = TextUtils.TruncateAt.End;
|
||||
_detailText.SetPadding((int)context.ToPixels(15), padding, padding, padding);
|
||||
_detailText.Visibility = ViewStates.Gone;
|
||||
_detailText.SetTextAppearanceCompat(context, global::Android.Resource.Style.TextAppearanceSmall);
|
||||
TextViewCompat.SetTextAppearance(_detailText, global::Android.Resource.Style.TextAppearanceSmall);
|
||||
|
||||
using (var lp = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent))
|
||||
textLayout.AddView(_detailText, lp);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using Android.Content;
|
||||
using Android.Support.V4.Widget;
|
||||
using Android.Text;
|
||||
using Android.Views;
|
||||
using Android.Views.InputMethods;
|
||||
|
@ -29,7 +30,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
SetPadding((int)context.ToPixels(15), padding, padding, padding);
|
||||
|
||||
_label = new TextView(context);
|
||||
_label.SetTextAppearanceCompat(context, global::Android.Resource.Style.TextAppearanceSmall);
|
||||
TextViewCompat.SetTextAppearance(_label, global::Android.Resource.Style.TextAppearanceSmall);
|
||||
|
||||
var layoutParams = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent) { Gravity = GravityFlags.CenterVertical };
|
||||
using (layoutParams)
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
using Android.Content;
|
||||
using Android.OS;
|
||||
using Android.Widget;
|
||||
|
||||
namespace Xamarin.Forms.Platform.Android
|
||||
{
|
||||
internal static class TextViewExtensions
|
||||
{
|
||||
public static void SetTextAppearanceCompat(this TextView textView, Context context, int resId)
|
||||
{
|
||||
if ((int)Build.VERSION.SdkInt < 23)
|
||||
{
|
||||
#pragma warning disable 618 // Using older version of SetTextAppearance for compatibility with API 15-22
|
||||
textView.SetTextAppearance(context, resId);
|
||||
#pragma warning restore 618
|
||||
}
|
||||
else
|
||||
textView.SetTextAppearance(resId);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -192,7 +192,6 @@
|
|||
<Compile Include="Renderers\ToolbarImageButton.cs" />
|
||||
<Compile Include="Renderers\ViewGroupExtensions.cs" />
|
||||
<Compile Include="TapGestureHandler.cs" />
|
||||
<Compile Include="TextViewExtensions.cs" />
|
||||
<Compile Include="TextColorSwitcher.cs" />
|
||||
<Compile Include="ViewInitializedEventArgs.cs" />
|
||||
<Compile Include="VisualElementChangedEventArgs.cs" />
|
||||
|
|
Загрузка…
Ссылка в новой задаче