当前位置: 首页>>代码示例>>C#>>正文


C# TextView.SetLines方法代码示例

本文整理汇总了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.";
//.........这里部分代码省略.........
开发者ID:RickySan65,项目名称:xamarin-forms-samples,代码行数:101,代码来源:HomePage.xaml.cs

示例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);
		}
开发者ID:aliarobinson,项目名称:SpeedyChef_375,代码行数:6,代码来源:MealPlannerCalendar.cs

示例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;
		}
开发者ID:cbudo,项目名称:SpeedyChef,代码行数:49,代码来源:MealPlannerCalendar.cs


注:本文中的Android.Widget.TextView.SetLines方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。