本文整理汇总了C#中Android.Widget.TextView.SetLines方法的典型用法代码示例。如果您正苦于以下问题:C# TextView.SetLines方法的具体用法?C# TextView.SetLines怎么用?C# TextView.SetLines使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Widget.TextView
的用法示例。
在下文中一共展示了TextView.SetLines方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HomePage
public HomePage ()
{
InitializeComponent ();
#if __IOS__
const string originalText = "Native UILabel.";
const string longerText = "Native UILabel. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vel elit orci. Nam sollicitudin consectetur congue.";
var uiLabel = new UILabel {
MinimumFontSize = 14f,
Lines = 0,
LineBreakMode = UILineBreakMode.WordWrap,
Text = originalText,
};
stackLayout.Children.Add (uiLabel);
var uiButton = new UIButton (UIButtonType.RoundedRect);
uiButton.SetTitle ("Change Text", UIControlState.Normal);
uiButton.Font = UIFont.FromName ("Helvetica", 14f);
uiButton.TouchUpInside += (sender, args) => {
uiLabel.Text = uiLabel.Text == originalText ? longerText : originalText;
uiLabel.SizeToFit ();
};
stackLayout.Children.Add (uiButton);
var explanation1 = new UILabel {
MinimumFontSize = 14f,
Lines = 0,
LineBreakMode = UILineBreakMode.WordWrap,
Text = "The next control is a CustomControl (a customized UILabel with a bad SizeThatFits implementation).",
};
stackLayout.Children.Add (explanation1);
var brokenControl = new CustomControl {
MinimumFontSize = 14,
Lines = 0,
LineBreakMode = UILineBreakMode.WordWrap,
Text = "This control has incorrect sizing - there's empty space above and below it."
};
stackLayout.Children.Add (brokenControl);
var explanation2 = new UILabel {
MinimumFontSize = 14f,
Lines = 0,
LineBreakMode = UILineBreakMode.WordWrap,
Text = "The next control is a CustomControl, but an override to the GetDesiredSize method is passed in when adding the control to the layout.",
};
stackLayout.Children.Add (explanation2);
var fixedControl = new CustomControl {
MinimumFontSize = 14,
Lines = 0,
LineBreakMode = UILineBreakMode.WordWrap,
Text = "This control has correct sizing - there's no empty space above and below it."
};
stackLayout.Children.Add (fixedControl, FixSize);
#endif
#if __ANDROID__
const string originalText = "Native TextView.";
const string longerText = "Native TextView. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vel elit orci. Nam sollicitudin consectetur congue.";
var textView = new TextView (Forms.Context) { Text = originalText, TextSize = 14 };
textView.SetSingleLine (false);
textView.SetLines (3);
stackLayout.Children.Add (textView);
var button = new Android.Widget.Button (Forms.Context) { Text = "Change Text" };
button.Click += (sender, args) => {
textView.Text = textView.Text == originalText ? longerText : originalText;
};
stackLayout.Children.Add (button);
var explanation1 = new TextView (Forms.Context) {
Text = "The next control is a CustomControl (a customized TextView with a bad OnMeasure implementation).",
TextSize = 14
};
stackLayout.Children.Add (explanation1);
var brokenControl = new CustomControl (Forms.Context) {
Text = "This control has incorrect sizing - it doesn't occupy the available width of the device.",
TextSize = 14
};
stackLayout.Children.Add (brokenControl);
var explanation2 = new TextView (Forms.Context) {
Text = "The next control is a CustomControl, but with a custom GetDesiredSize delegate to accomodate it's sizing problem.",
TextSize = 14
};
stackLayout.Children.Add (explanation2);
var goodControl = new CustomControl (Forms.Context) {
Text = "This control has correct sizing - it occupies the available width of the device.",
TextSize = 14
};
stackLayout.Children.Add (goodControl, FixSize);
#endif
#if WINDOWS_PHONE_APP
const string originalText = "Native TextBlock.";
//.........这里部分代码省略.........
示例2: handleRecipeInfo
public void handleRecipeInfo (TextView recipeInfo, LinearLayout.LayoutParams rill, JsonValue recipeResult) {
recipeInfo.Text = handleRecipeJson (recipeResult);
recipeInfo.SetTextAppearance (this, Android.Resource.Style.TextAppearanceSmall);
recipeInfo.SetLines (1);
recipeInfo.SetPadding (10, 0, 0, 0);
}
示例3: CreateMealInfo
/// <summary>
/// Creates the meal info area in the programmitcally generated by Json.
/// </summary>
/// <returns>The meal info container for orginal Json calls.</returns>
/// <param name="json">Json from original call to be parsed.</param>
/// <param name="recipeResult">Recipe result (Json) using info from original Json.</param>
/// <param name="count">Count used for creating unique ids.</param>
private LinearLayout CreateMealInfo (JsonValue json,
JsonValue recipeResult, int count)
{
LinearLayout mealInfo = new LinearLayout (this);
mealInfo.Orientation = Orientation.Horizontal;
mealInfo.SetMinimumWidth (25);
mealInfo.SetMinimumHeight (25);
LinearLayout.LayoutParams mealInfoLL =
new LinearLayout.LayoutParams (LinearLayout.LayoutParams.MatchParent,
LinearLayout.LayoutParams.WrapContent);
mealInfoLL.SetMargins (5, 5, 5, 5);
mealInfo.LayoutParameters = mealInfoLL;
mealInfo.Id = count * 20 + 7;
// Set image icon
ImageView dinerIcon = new ImageView (this);
dinerIcon.SetImageResource (Resource.Drawable.gray_person);
dinerIcon.LayoutParameters = new
LinearLayout.LayoutParams (50, LinearLayout.LayoutParams.MatchParent);
// Finish setting the image icon
TextView mealSize = new TextView (this);
TextView recipeInfo = new TextView (this);
recipeInfo.Text = handleRecipeJson (recipeResult);
recipeInfo.SetTextAppearance (this, Android.Resource.Style.TextAppearanceSmall);
recipeInfo.SetLines (1);
LinearLayout.LayoutParams rill =
new LinearLayout.LayoutParams (LinearLayout.LayoutParams.WrapContent,
LinearLayout.LayoutParams.WrapContent);
recipeInfo.LayoutParameters = rill;
mealSize.SetTextAppearance (this, Android.Resource.Style.TextAppearanceSmall);
LinearLayout.LayoutParams tvll =
new LinearLayout.LayoutParams (LinearLayout.LayoutParams.WrapContent,
LinearLayout.LayoutParams.WrapContent);
mealSize.LayoutParameters = tvll;
mealSize.Text = json ["Mealsize"].ToString ();
recipeInfo.SetPadding (10, 0, 0, 0);
mealSize.Gravity = GravityFlags.Right;
// Add image icon
mealInfo.AddView (mealSize);
mealInfo.AddView (dinerIcon);
mealInfo.AddView (recipeInfo);
return mealInfo;
}