本文整理汇总了C#中Android.Views.View.GetLocationInWindow方法的典型用法代码示例。如果您正苦于以下问题:C# View.GetLocationInWindow方法的具体用法?C# View.GetLocationInWindow怎么用?C# View.GetLocationInWindow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Views.View
的用法示例。
在下文中一共展示了View.GetLocationInWindow方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetShowcasePointFromView
public static Point GetShowcasePointFromView(View view, ShowcaseView.ConfigOptions options)
{
var result = new Point();
if (options.Insert == ShowcaseView.INSERTTOVIEW)
{
result.X = view.Left + view.Width / 2;
result.Y = view.Top + view.Height / 2;
}
else
{
var coordinates = new int[2];
view.GetLocationInWindow(coordinates);
result.X = coordinates[0] + view.Width / 2;
result.Y = coordinates[1] + view.Height / 2;
}
return result;
}
示例2: GetFretMetrics
/// <summary>
/// Gets the X, Y, Width, and Height of the fret which is represented on the screen by a view.
/// </summary>
/// <param name="fretNum">The number of the requested fret.</param>
/// <returns>Returns the metrics of the requested fret.</returns>
private FretMetrics GetFretMetrics(GuitarFret fretNum)
{
//Initialize a dummy fret.
View fret = new View(_currentActivity);
//Get the correct fret number.
/*if (_currentActivity.Title == "TutorActivity")
else if (_currentActivity.Title == "PlayerActivity")
else if (_currentActivity.Title == "RecorderActivity")*/
switch (fretNum)
{
case GuitarFret.OpenString:
fret = _currentActivity.FindViewById(Resource.Id.openString);
break;
case GuitarFret.Fret1:
fret = _currentActivity.FindViewById(Resource.Id.fret1);
break;
case GuitarFret.Fret2:
fret = _currentActivity.FindViewById(Resource.Id.fret2);
break;
case GuitarFret.Fret3:
fret = _currentActivity.FindViewById(Resource.Id.fret3);
break;
case GuitarFret.Fret4:
fret = _currentActivity.FindViewById(Resource.Id.fret4);
break;
case GuitarFret.Fret5:
fret = _currentActivity.FindViewById(Resource.Id.fret5);
break;
case GuitarFret.Fret6:
fret = _currentActivity.FindViewById(Resource.Id.fret6);
break;
}
//Get the X & Y coordinates of the fret on the screen.
int[] coordinates = new int[2];
fret.GetLocationInWindow(coordinates);
//Summerize X, Y, Width, and Height.
FretMetrics metrics = new FretMetrics(
(int)fret.GetX(), //coordinates[0],
(int)((TableRow)fret.Parent).GetY(), //coordinates[1],
fret.MeasuredWidth,
fret.MeasuredHeight);
Log.Info("", fret.Tag.ToString());
Log.Info(fret.GetX().ToString(), fret.GetY().ToString());
Log.Info(coordinates[0].ToString(), coordinates[1].ToString());
Log.Info(fret.Width.ToString(), fret.Height.ToString());
Log.Info("Left", fret.Left.ToString());
Log.Info("Right", fret.Right.ToString());
Log.Info("Top", fret.Top.ToString());
Log.Info("Bottom", fret.Bottom.ToString());
return metrics;
}