本文整理汇总了C#中TextView.SetTextSize方法的典型用法代码示例。如果您正苦于以下问题:C# TextView.SetTextSize方法的具体用法?C# TextView.SetTextSize怎么用?C# TextView.SetTextSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextView
的用法示例。
在下文中一共展示了TextView.SetTextSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MeasureTextSize
public static Xamarin.Forms.Size MeasureTextSize(string text, double width,
double fontSize, string fontName = null)
{
var textView = new TextView(global::Android.App.Application.Context);
textView.Typeface = GetTypeface(fontName);
textView.SetText(text, TextView.BufferType.Normal);
textView.SetTextSize(ComplexUnitType.Px, (float)fontSize);
int widthMeasureSpec = Android.Views.View.MeasureSpec.MakeMeasureSpec(
(int)width, MeasureSpecMode.AtMost);
int heightMeasureSpec = Android.Views.View.MeasureSpec.MakeMeasureSpec(
0, MeasureSpecMode.Unspecified);
textView.Measure(widthMeasureSpec, heightMeasureSpec);
return new Xamarin.Forms.Size((double)textView.MeasuredWidth,
(double)textView.MeasuredHeight);
}
示例2: MessageListItem
public MessageListItem( Context context )
: base(context)
{
SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BackgroundColor ) );
LayoutParameters = new AbsListView.LayoutParams( LayoutParams.MatchParent, LayoutParams.MatchParent );
Orientation = Orientation.Vertical;
LinearLayout contentLayout = new LinearLayout( Rock.Mobile.PlatformSpecific.Android.Core.Context );
contentLayout.LayoutParameters = new LinearLayout.LayoutParams( LayoutParams.MatchParent, LayoutParams.MatchParent );
contentLayout.Orientation = Orientation.Horizontal;
AddView( contentLayout );
TitleLayout = new LinearLayout( Rock.Mobile.PlatformSpecific.Android.Core.Context );
TitleLayout.LayoutParameters = new LinearLayout.LayoutParams( LayoutParams.MatchParent, LayoutParams.WrapContent );
TitleLayout.Orientation = Orientation.Vertical;
( (LinearLayout.LayoutParams)TitleLayout.LayoutParameters ).Weight = 1;
( (LinearLayout.LayoutParams)TitleLayout.LayoutParameters ).Gravity = GravityFlags.CenterVertical;
( (LinearLayout.LayoutParams)TitleLayout.LayoutParameters ).LeftMargin = 25;
( (LinearLayout.LayoutParams)TitleLayout.LayoutParameters ).TopMargin = 50;
( (LinearLayout.LayoutParams)TitleLayout.LayoutParameters ).BottomMargin = 50;
contentLayout.AddView( TitleLayout );
Title = new TextView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
Title.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
Title.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Bold ), TypefaceStyle.Normal );
Title.SetTextSize( Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Medium_FontSize );
Title.SetSingleLine( );
Title.Ellipsize = Android.Text.TextUtils.TruncateAt.End;
Title.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Label_TextColor ) );
TitleLayout.AddView( Title );
Date = new TextView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
Date.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
Date.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Regular ), TypefaceStyle.Normal );
Date.SetTextSize( Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize );
Date.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor ) );
TitleLayout.AddView( Date );
Speaker = new TextView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
Speaker.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
Speaker.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Regular ), TypefaceStyle.Normal );
Speaker.SetTextSize( Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize );
Speaker.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor ) );
Speaker.SetMaxLines( 1 );
TitleLayout.AddView( Speaker );
// add our own custom seperator at the bottom
View seperator = new View( Rock.Mobile.PlatformSpecific.Android.Core.Context );
seperator.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MatchParent, 0 );
seperator.LayoutParameters.Height = 2;
seperator.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) );
AddView( seperator );
// setup the buttons
LinearLayout buttonLayout = new LinearLayout( Rock.Mobile.PlatformSpecific.Android.Core.Context );
buttonLayout.LayoutParameters = new LinearLayout.LayoutParams( LayoutParams.MatchParent, LayoutParams.MatchParent );
( (LinearLayout.LayoutParams)buttonLayout.LayoutParameters ).Weight = 1;
buttonLayout.Orientation = Orientation.Horizontal;
contentLayout.AddView( buttonLayout );
Typeface buttonFontFace = Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( PrivateControlStylingConfig.Icon_Font_Secondary );
ListenButton = new Button( Rock.Mobile.PlatformSpecific.Android.Core.Context );
ListenButton.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
( (LinearLayout.LayoutParams)ListenButton.LayoutParameters ).Weight = 1;
( (LinearLayout.LayoutParams)ListenButton.LayoutParameters ).Gravity = GravityFlags.CenterVertical;
ListenButton.SetTypeface( buttonFontFace, TypefaceStyle.Normal );
ListenButton.SetTextSize( Android.Util.ComplexUnitType.Dip, PrivateNoteConfig.Details_Table_IconSize );
ListenButton.Text = PrivateNoteConfig.Series_Table_Listen_Icon;
ListenButton.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( NoteConfig.Details_Table_IconColor ) );
ListenButton.Background = null;
buttonLayout.AddView( ListenButton );
WatchButton = new Button( Rock.Mobile.PlatformSpecific.Android.Core.Context );
WatchButton.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
( (LinearLayout.LayoutParams)WatchButton.LayoutParameters ).Weight = 1;
( (LinearLayout.LayoutParams)WatchButton.LayoutParameters ).Gravity = GravityFlags.CenterVertical;
WatchButton.SetTypeface( buttonFontFace, TypefaceStyle.Normal );
WatchButton.SetTextSize( Android.Util.ComplexUnitType.Dip, PrivateNoteConfig.Details_Table_IconSize );
WatchButton.Text = PrivateNoteConfig.Series_Table_Watch_Icon;
WatchButton.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( NoteConfig.Details_Table_IconColor ) );
WatchButton.Background = null;
buttonLayout.AddView( WatchButton );
TakeNotesButton = new Button( Rock.Mobile.PlatformSpecific.Android.Core.Context );
TakeNotesButton.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
( (LinearLayout.LayoutParams)TakeNotesButton.LayoutParameters ).Weight = 1;
( (LinearLayout.LayoutParams)TakeNotesButton.LayoutParameters ).Gravity = GravityFlags.CenterVertical;
TakeNotesButton.SetTypeface( buttonFontFace, TypefaceStyle.Normal );
TakeNotesButton.SetTextSize( Android.Util.ComplexUnitType.Dip, PrivateNoteConfig.Details_Table_IconSize );
TakeNotesButton.Text = PrivateNoteConfig.Series_Table_TakeNotes_Icon;
TakeNotesButton.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( NoteConfig.Details_Table_IconColor ) );
TakeNotesButton.Background = null;
buttonLayout.AddView( TakeNotesButton );
ListenButton.Click += (object sender, EventArgs e ) =>
{
ParentAdapter.OnClick( Position, 0 );
};
//.........这里部分代码省略.........
示例3: ListItem
public ListItem( Context context )
: base(context)
{
Orientation = Android.Widget.Orientation.Vertical;
SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BackgroundColor ) );
LinearLayout contentLayout = new LinearLayout( Rock.Mobile.PlatformSpecific.Android.Core.Context );
contentLayout.Orientation = Android.Widget.Orientation.Horizontal;
contentLayout.LayoutParameters = new LinearLayout.LayoutParams( LayoutParams.WrapContent, LayoutParams.WrapContent );
AddView( contentLayout );
Thumbnail = new Rock.Mobile.PlatformSpecific.Android.Graphics.AspectScaledImageView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
Thumbnail.LayoutParameters = new LinearLayout.LayoutParams( (int)Rock.Mobile.Graphics.Util.UnitToPx( PrivateConnectConfig.MainPage_ThumbnailDimension ), (int)Rock.Mobile.Graphics.Util.UnitToPx( PrivateConnectConfig.MainPage_ThumbnailDimension ) );
( (LinearLayout.LayoutParams)Thumbnail.LayoutParameters ).TopMargin = 25;
( (LinearLayout.LayoutParams)Thumbnail.LayoutParameters ).BottomMargin = 25;
( (LinearLayout.LayoutParams)Thumbnail.LayoutParameters ).Gravity = GravityFlags.CenterVertical;
Thumbnail.SetScaleType( ImageView.ScaleType.CenterCrop );
contentLayout.AddView( Thumbnail );
TitleLayout = new LinearLayout( Rock.Mobile.PlatformSpecific.Android.Core.Context );
TitleLayout.Orientation = Android.Widget.Orientation.Vertical;
TitleLayout.LayoutParameters = new LinearLayout.LayoutParams( LayoutParams.WrapContent, LayoutParams.WrapContent );
( (LinearLayout.LayoutParams)TitleLayout.LayoutParameters ).Gravity = GravityFlags.CenterVertical;
( (LinearLayout.LayoutParams)TitleLayout.LayoutParameters ).LeftMargin = 25;
contentLayout.AddView( TitleLayout );
Title = new TextView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
Title.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
Title.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Regular ), TypefaceStyle.Normal );
Title.SetTextSize( Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Medium_FontSize );
Title.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_ActiveTextColor ) );
Title.SetSingleLine( );
Title.Ellipsize = Android.Text.TextUtils.TruncateAt.End;
TitleLayout.AddView( Title );
// fill the remaining space with a dummy view, and that will align our chevron to the right
View dummyView = new View( Rock.Mobile.PlatformSpecific.Android.Core.Context );
dummyView.LayoutParameters = new LinearLayout.LayoutParams( 0, 0 );
( (LinearLayout.LayoutParams)dummyView.LayoutParameters ).Weight = 1;
contentLayout.AddView( dummyView );
Chevron = new TextView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
Chevron.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
( (LinearLayout.LayoutParams)Chevron.LayoutParameters ).Gravity = GravityFlags.CenterVertical | GravityFlags.Right;
Typeface fontFace = Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( PrivateControlStylingConfig.Icon_Font_Secondary );
Chevron.SetTypeface( fontFace, TypefaceStyle.Normal );
Chevron.SetTextSize( Android.Util.ComplexUnitType.Dip, PrivateConnectConfig.MainPage_Table_IconSize );
Chevron.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor ) );
Chevron.Text = PrivateConnectConfig.MainPage_Table_Navigate_Icon;
contentLayout.AddView( Chevron );
// add our own custom seperator at the bottom
Seperator = new View( Rock.Mobile.PlatformSpecific.Android.Core.Context );
Seperator.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MatchParent, 0 );
Seperator.LayoutParameters.Height = 2;
Seperator.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) );
AddView( Seperator );
}
示例4: MessagePrimaryListItem
//
public MessagePrimaryListItem( Context context )
: base(context)
{
SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_Color ) );
Orientation = Orientation.Vertical;
Thumbnail = new Rock.Mobile.PlatformSpecific.Android.Graphics.AspectScaledImageView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
Thumbnail.LayoutParameters = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent );
Thumbnail.SetScaleType( ImageView.ScaleType.CenterCrop );
AddView( Thumbnail );
Title = new TextView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
Title.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
Title.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Bold ), TypefaceStyle.Normal );
Title.SetTextSize( Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Large_FontSize );
Title.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Label_TextColor ) );
( (LinearLayout.LayoutParams)Title.LayoutParameters ).TopMargin = 25;
( (LinearLayout.LayoutParams)Title.LayoutParameters ).LeftMargin = 25;
AddView( Title );
DateRange = new TextView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
DateRange.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
DateRange.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Light ), TypefaceStyle.Normal );
DateRange.SetTextSize( Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize );
DateRange.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Label_TextColor ) );
( (LinearLayout.LayoutParams)DateRange.LayoutParameters ).TopMargin = 0;
( (LinearLayout.LayoutParams)DateRange.LayoutParameters ).LeftMargin = 25;
AddView( DateRange );
Desc = new TextView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
Desc.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
Desc.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Light ), TypefaceStyle.Normal );
Desc.SetTextSize( Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize );
Desc.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Label_TextColor ) );
( (LinearLayout.LayoutParams)Desc.LayoutParameters ).TopMargin = 10;
( (LinearLayout.LayoutParams)Desc.LayoutParameters ).LeftMargin = 25;
( (LinearLayout.LayoutParams)Desc.LayoutParameters ).RightMargin = 25;
( (LinearLayout.LayoutParams)Desc.LayoutParameters ).BottomMargin = 25;
AddView( Desc );
}
示例5: PrimaryListItem
public PrimaryListItem( Context context )
: base(context)
{
SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_Color ) );
Orientation = Android.Widget.Orientation.Vertical;
Billboard = new Rock.Mobile.PlatformSpecific.Android.Graphics.AspectScaledImageView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
Billboard.LayoutParameters = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent );
Billboard.SetScaleType( ImageView.ScaleType.CenterCrop );
AddView( Billboard );
Title = new TextView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
Title.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
Title.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Bold ), TypefaceStyle.Normal );
Title.SetTextSize( Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Large_FontSize );
Title.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_ActiveTextColor ) );
Title.Text = ConnectStrings.Main_Connect_Header;
( (LinearLayout.LayoutParams)Title.LayoutParameters ).TopMargin = 5;
( (LinearLayout.LayoutParams)Title.LayoutParameters ).LeftMargin = 25;
( (LinearLayout.LayoutParams)Title.LayoutParameters ).BottomMargin = 5;
AddView( Title );
}