Rect LayoutPopup () { var popup = _popupBasePage.PopupViews [_currentPopup] as SlidePopupView; var metrics = _pageRenderer.Resources.DisplayMetrics; Point? targetPoint = null; if (popup.TargetControl != null) { TypedValue tv = new TypedValue (); int actionBarHeight = 0; if (Android.App.Application.Context.Theme.ResolveAttribute (Android.Resource.Attribute.ActionBarSize, tv, true)) { actionBarHeight = TypedValue.ComplexToDimensionPixelSize (tv.Data, Android.App.Application.Context.Resources.DisplayMetrics); } var targetRenderer = Platform.GetRenderer (popup.TargetControl); int [] array = new int [2]; targetRenderer.View.GetLocationInWindow (array); targetPoint = new Point { X = array [0] / metrics.Density, Y = (array [1] / metrics.Density) - (actionBarHeight / metrics.Density) }; } popup.CalucatePosition (targetPoint); double x = popup.LeftMargin; double y = popup.TopMargin; double width = popup.WidthRequest <= 0 ? ScreenSizeHelper.ScreenWidth - popup.LeftMargin * 2 : popup.WidthRequest; double height = popup.HeightRequest <= 0 ? ScreenSizeHelper.ScreenHeight - popup.TopMargin * 2 : popup.HeightRequest; popup.Layout (new Xamarin.Forms.Rectangle (x, y, width, height)); _popupRenderer.UpdateLayout (); return new Rect { left = x * metrics.Density, top = y * metrics.Density, right = (x + width) * metrics.Density, bottom = (y + height) * metrics.Density }; }
public override View GetView(int position, View convertView, ViewGroup parent) { View view = base.GetView(position, convertView, parent); var typedVal = new TypedValue(); var activity = Xamarin.Essentials.Platform.CurrentActivity; if (activity.Theme.ResolveAttribute(Resource.Attribute.dialogPreferredPadding, typedVal, true)) { var padding = TypedValue.ComplexToDimensionPixelSize(typedVal.Data, activity.Resources.DisplayMetrics); view.SetPadding(padding, 0, padding, 0); } TextView textView = view.FindViewById <TextView>(global::Android.Resource.Id.Text1); textView.SetTextSize(ComplexUnitType.Sp, 16); textView.SetCompoundDrawablesWithIntrinsicBounds(Resource.Drawable.abc_ic_star_black_16dp, 0, 0, 0); int dp5 = (int)(5 * Xamarin.Essentials.DeviceDisplay.MainDisplayInfo.Density + 0.5f); textView.CompoundDrawablePadding = dp5; return(view); }
protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); Xamarin.FormsGoogleMaps.Init(this, bundle); CachedImageRenderer.Init(); this.OverridePendingTransition(Resource.Animation.design_snackbar_in, Resource.Animation.design_snackbar_out); var dm = new DisplayMetrics(); this.WindowManager.DefaultDisplay.GetMetrics(dm); App.ScreenWidth = dm.WidthPixels / dm.ScaledDensity; App.ScreenHeight = dm.HeightPixels / dm.ScaledDensity; App.Scale = dm.ScaledDensity; // get the action bar height var value = new TypedValue(); if (this.Theme.ResolveAttribute(Android.Resource.Attribute.ActionBarSize, value, true)) { var height = TypedValue.ComplexToDimensionPixelSize(value.Data, this.Resources.DisplayMetrics); App.NavigationBarHeight = height / App.Scale; } this.LoadApplication(new App()); }
public ActionImageRenderer(Context context) { Context = context; AnimatorUpdateListener = new AnonymousAnimatorUpdateListener(amor => { this.ComputeRender((float)amor.AnimatedValue); Callback.InvalidateDrawable(null); }); TypedValue tv = new TypedValue(); if (context.Theme.ResolveAttribute(Android.Resource.Attribute.ActionBarSize, tv, true)) { ActionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, context.Resources.DisplayMetrics); } var dm = context.Resources.DisplayMetrics; float density = dm.Density; Width = dm.WidthPixels; Height = dm.HeightPixels - StatusBarHeight - ActionBarHeight; Duration = ANIMATION_DURATION; RenderAnimator = ValueAnimator.OfFloat(0.0f, 1.0f); RenderAnimator.RepeatCount = Animation.Infinite; RenderAnimator.RepeatMode = ValueAnimatorRepeatMode.Restart; RenderAnimator.SetDuration(Duration); RenderAnimator.SetInterpolator(new LinearInterpolator()); RenderAnimator.AddUpdateListener(AnimatorUpdateListener); }
private void HomeContentLayout() { //HomeLabel profileContentLabel = new TextView(context); profileContentLabel.TextSize = 20; profileContentLabel.Text = "Home"; profileContentLabel.SetTextColor(Color.White); profileContentLabel.Gravity = GravityFlags.Center; //linearLayout LinearLayout linearLayout = new LinearLayout(context); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, getDimensionPixelSize(context, Resource.Dimension.nav_drawer_header_ht), GravityFlags.Center); layoutParams.SetMargins(10, 0, 0, 0); linearLayout.SetPadding(10, 0, 0, 0); linearLayout.AddView(iconbutton); linearLayout.AddView(profileContentLabel, layoutParams); linearLayout.SetBackgroundColor(Color.Rgb(47, 173, 227)); TypedValue tv = new TypedValue(); if (context.Theme.ResolveAttribute(Android.Resource.Attribute.ActionBarSize, tv, true)) { actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, context.Resources.DisplayMetrics); } height = Convert.ToInt32(context.Resources.DisplayMetrics.HeightPixels - actionBarHeight); width = context.Resources.DisplayMetrics.WidthPixels; //linear2 linear2 = new LinearLayout(context); linear2.Orientation = Orientation.Vertical; linear2.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); FrameLayout.LayoutParams layout2 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent, GravityFlags.Center); linear2.AddView(linearLayout, layout2); }
int ActionBarHeight() { int attr = Microsoft.Maui.Controls.Compatibility.Resource.Attribute.actionBarSize; int actionBarHeight; using (var tv = new TypedValue()) { actionBarHeight = 0; if (Context.Theme.ResolveAttribute(attr, tv, true)) { actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, Resources.DisplayMetrics); } } if (actionBarHeight <= 0) { return(DeviceDisplay.MainDisplayInfo.Orientation.IsPortrait() ? (int)Context.ToPixels(56) : (int)Context.ToPixels(48)); } if (Context.GetActivity().Window.Attributes.Flags.HasFlag(WindowManagerFlags.TranslucentStatus) || Context.GetActivity().Window.Attributes.Flags.HasFlag(WindowManagerFlags.TranslucentNavigation)) { if (_toolbar.PaddingTop == 0) { _toolbar.SetPadding(0, GetStatusBarHeight(), 0, 0); } return(actionBarHeight + GetStatusBarHeight()); } return(actionBarHeight); }
private void InitialMethod() { frame = new FrameLayout(con); totalHeight = con.Resources.DisplayMetrics.HeightPixels; TypedValue tv = new TypedValue(); if (con.Theme.ResolveAttribute(Android.Resource.Attribute.ActionBarSize, tv, true)) { actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, con.Resources.DisplayMetrics); } navigationBarHeight = getNavigationBarHeight(con); totalHeight = totalHeight - navigationBarHeight - actionBarHeight; numerHeight = getDimensionPixelSize(con, Resource.Dimension.numeric_txt_ht); width = con.Resources.DisplayMetrics.WidthPixels - 40; mainFrameLayout = new FrameLayout(con); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent, GravityFlags.FillVertical); mainFrameLayout.LayoutParameters = layoutParams; //mainLayout mainLayout = new LinearLayout(con); mainLayout.LayoutParameters = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, (int)(totalHeight * 0.6), GravityFlags.Top | GravityFlags.CenterHorizontal); mainLayout.SetGravity(GravityFlags.FillVertical); mainLayout.SetPadding(10, 10, 10, 10); mainLayout.SetBackgroundColor(Color.White); mainLayout.Orientation = Orientation.Vertical; }
protected override void OnAnimatorAttached() { base.OnAnimatorAttached(); mHeaderText = Header.FindViewById(Resource.Id.header_text_layout); var tv = new TypedValue(); int actionBarHeight = 0; if (mContext.Theme.ResolveAttribute(Android.Resource.Attribute.ActionBarSize, tv, true)) { actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, mContext.Resources.DisplayMetrics); } mMinHeightTextHeader = mContext.Resources.GetDimensionPixelSize(Resource.Dimension.min_height_textheader_materiallike); mHeightStartAnimation = actionBarHeight + mMinHeightTextHeader; valueAnimator = ValueAnimator.OfInt(0); valueAnimator.SetDuration(mContext.Resources.GetInteger(Android.Resource.Integer.ConfigShortAnimTime)); valueAnimator.Update += (sender, e) => { ViewGroup.LayoutParams layoutParams = mHeaderText.LayoutParameters; layoutParams.Height = (int)e.Animation.AnimatedValue; mHeaderText.LayoutParameters = layoutParams; }; }
protected virtual void LoadView(IShellContext shellContext) { var context = shellContext.AndroidContext; // Android designer can't load fragments or resources from layouts if (context.IsDesignerContext()) { _rootView = new FrameLayout(context); return; } var coordinator = LayoutInflater.FromContext(context).Inflate(Resource.Layout.FlyoutContent, null); var recycler = coordinator.FindViewById <RecyclerView>(Resource.Id.flyoutcontent_recycler); var appBar = coordinator.FindViewById <AppBarLayout>(Resource.Id.flyoutcontent_appbar); _rootView = coordinator; appBar.AddOnOffsetChangedListener(this); int actionBarHeight = (int)context.ToPixels(56); _headerView = new HeaderContainer(context, ((IShellController)shellContext.Shell).FlyoutHeader) { MatchWidth = true }; _headerView.SetMinimumHeight(actionBarHeight); _headerView.LayoutParameters = new AppBarLayout.LayoutParams(LP.MatchParent, LP.WrapContent) { ScrollFlags = AppBarLayout.LayoutParams.ScrollFlagScroll }; appBar.AddView(_headerView); var adapter = new ShellFlyoutRecyclerAdapter(shellContext, OnElementSelected); recycler.SetPadding(0, (int)context.ToPixels(20), 0, 0); recycler.SetClipToPadding(false); recycler.SetLayoutManager(new LinearLayoutManager(context, (int)Orientation.Vertical, false)); recycler.SetAdapter(adapter); var metrics = context.Resources.DisplayMetrics; var width = Math.Min(metrics.WidthPixels, metrics.HeightPixels); using (TypedValue tv = new TypedValue()) { if (context.Theme.ResolveAttribute(global::Android.Resource.Attribute.ActionBarSize, tv, true)) { actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, metrics); } } width -= actionBarHeight; coordinator.LayoutParameters = new LP(width, LP.MatchParent); UpdateFlyoutHeaderBehavior(); _shellContext.Shell.PropertyChanged += OnShellPropertyChanged; UpdateFlyoutBackgroundColor(); }
public static Int32 GetAttributePixelSize(Context context, Int32 attributeId) { TypedValue value = new TypedValue(); return(context.Theme.ResolveAttribute(attributeId, value, true) ? TypedValue.ComplexToDimensionPixelSize(value.Data, context.Resources.DisplayMetrics) : 0); }
public static int getActionBarSize(Context context) { TypedValue tv = new TypedValue(); if (context.Theme.ResolveAttribute(AndroidResource.Attribute.ActionBarSize, tv, true)) { int actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, context.Resources.DisplayMetrics); return(actionBarHeight); } return(0); }
public static int ActionBarHeight(this Context activity) { TypedValue tv = new TypedValue(); if (activity.Theme.ResolveAttribute(Android.Resource.Attribute.ActionBarSize, tv, true)) { return(TypedValue.ComplexToDimensionPixelSize(tv.Data, activity.Resources.DisplayMetrics)); } return(-1); }
public void getActionbarHeight() { // Calculate ActionBar height var metrics = Resources.DisplayMetrics; TypedValue tv = new TypedValue(); if (Theme.ResolveAttribute(Android.Resource.Attribute.ActionBarSize, tv, true)) { var actionbarH = TypedValue.ComplexToDimensionPixelSize(tv.Data, Resources.DisplayMetrics); AppStatics.ActionBarHeight = (int)(actionbarH / metrics.Density); } }
private int getActionBarHeight(Context context) { int result = 0; if (Build.VERSION.SdkInt >= BuildVersionCodes.IceCreamSandwich) { TypedValue tv = new TypedValue(); context.Theme.ResolveAttribute(Android.Resource.Attribute.ActionBarSize, tv, true); result = TypedValue.ComplexToDimensionPixelSize(tv.Data, context.Resources.DisplayMetrics); } return(result); }
private int CalculateSizeOfToolbar() { int size = 0; TypedValue tv = new TypedValue(); if (Theme.ResolveAttribute(Android.Resource.Attribute.ActionBarSize, tv, true)) { size = TypedValue.ComplexToDimensionPixelSize(tv.Data, Resources.DisplayMetrics); } return(size); }
protected virtual void AttachFlyout(IShellContext context, AView content) { _content = content; _flyoutContent = context.CreateShellFlyoutContentRenderer(); // Depending on what you read the right edge of the drawer should be Max(56dp, actionBarSize) // from the right edge of the screen. Fine. Well except that doesn't account // for landscape devices, in which case its still, according to design // documents from google 56dp, except google doesn't do that with their own apps. // So we are just going to go ahead and do what google does here even though // this isn't what DrawerLayout does by default. // Oh then there is this rule about how wide it should be at most. It should not // at least according to docs be more than 6 * actionBarSize wide. Again non of // this is about landscape devices and google does not perfectly follow these // rules... so we'll kind of just... do our best. var metrics = Context.Resources.DisplayMetrics; var width = Math.Min(metrics.WidthPixels, metrics.HeightPixels); var actionBarHeight = (int)Context.ToPixels(56); using (var tv = new TypedValue()) { if (Context.Theme.ResolveAttribute(global::Android.Resource.Attribute.ActionBarSize, tv, true)) { actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, metrics); } } width -= actionBarHeight; var maxWidth = actionBarHeight * 6; width = Math.Min(width, maxWidth); _flyoutWidth = width; _flyoutContent.AndroidView.LayoutParameters = new LayoutParams(width, LP.MatchParent) { Gravity = (int)GravityFlags.Start }; AddView(content); AddView(_flyoutContent.AndroidView); AddDrawerListener(this); ((IShellController)context.Shell).AddFlyoutBehaviorObserver(this); }
private void InitialSettings(Context context) { frame = new FrameLayout(context); totalHeight = context.Resources.DisplayMetrics.HeightPixels; TypedValue tv = new TypedValue(); if (context.Theme.ResolveAttribute(Android.Resource.Attribute.ActionBarSize, tv, true)) { actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, context.Resources.DisplayMetrics); } navigationBarHeight = getNavigationBarHeight(context); totalHeight = (totalHeight - navigationBarHeight - actionBarHeight); }
private void InitialMethod() { frame = new FrameLayout(con); totalHeight = con.Resources.DisplayMetrics.HeightPixels; height = (int)(con.Resources.DisplayMetrics.HeightPixels); //-(actionBarHeight+statusBarHeight+navigationBarHeight)); TypedValue tv = new TypedValue(); if (con.Theme.ResolveAttribute(Android.Resource.Attribute.ActionBarSize, tv, true)) { actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, con.Resources.DisplayMetrics); } navigationBarHeight = getNavigationBarHeight(con); totalHeight = totalHeight - navigationBarHeight - actionBarHeight; }
private void InizialMethod() { frame = new FrameLayout(context); totalHeight = context.Resources.DisplayMetrics.HeightPixels; TypedValue tv = new TypedValue(); if (context.Theme.ResolveAttribute(Android.Resource.Attribute.ActionBarSize, tv, true)) { actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, context.Resources.DisplayMetrics); } navigationBarHeight = getNavigationBarHeight(context); totalHeight = (totalHeight - navigationBarHeight - actionBarHeight); mainLayout = new FrameLayout(context); mainLayout.LayoutParameters = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, (int)(totalHeight * 0.8), GravityFlags.Top | GravityFlags.CenterHorizontal); }
private int ActionBarHeight() { int attr = Resource.Attribute.actionBarSize; int actionBarHeight; using (var tv = new TypedValue()) { actionBarHeight = 0; if (Context.Theme.ResolveAttribute(attr, tv, true)) { actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, Resources.DisplayMetrics); } } return(actionBarHeight); }
int ActionBarHeight() { int attr = Resource.Attribute.actionBarSize; int actionBarHeight; using (var tv = new TypedValue()) { actionBarHeight = 0; if (Context.Theme.ResolveAttribute(attr, tv, true)) { actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, Resources.DisplayMetrics); } } //if (actionBarHeight <= 0) // return Device.Info.CurrentOrientation.IsPortrait() ? (int)Context.ToPixels(56) : (int)Context.ToPixels(48); return(actionBarHeight); }
private void InitialLayout() { frame = new FrameLayout(con); totalHeight = con.Resources.DisplayMetrics.HeightPixels; TypedValue tv = new TypedValue(); if (con.Theme.ResolveAttribute(Android.Resource.Attribute.ActionBarSize, tv, true)) { actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, con.Resources.DisplayMetrics); } navigationBarHeight = getNavigationBarHeight(con); totalHeight = totalHeight - navigationBarHeight - actionBarHeight; height = con.Resources.DisplayMetrics.HeightPixels / 2; width = con.Resources.DisplayMetrics.WidthPixels / 2; //pageLayout pageLayout = new LinearLayout(con); pageLayout.LayoutParameters = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent, GravityFlags.Top | GravityFlags.CenterHorizontal); pageLayout.Orientation = Android.Widget.Orientation.Vertical; }
//http://stackoverflow.com/questions/26564400/creating-a-preference-screen-with-support-v21-toolbar //How to change color of the back arrow in the new material theme? //http://gregshackles.com/changing-the-android-toolbars-back-arrow-color/ //http://stackoverflow.com/questions/26788464/how-to-change-color-of-the-back-arrow-in-the-new-material-theme public Toolbar CreateToolbarInDialog(Dialog dialog, Context context, int layoutToolbarId) { if (dialog == null) { return(null); } Toolbar result; if (Build.VERSION.SdkInt >= BuildVersionCodes.IceCreamSandwich) { var root = (LinearLayout)dialog.FindViewById(Android.Resource.Id.List).Parent; result = (Toolbar)LayoutInflater.From(context).Inflate(layoutToolbarId, root, false); root.AddView(result, 0); // insert at top } else { var root = (ViewGroup)dialog.FindViewById(Android.Resource.Id.Content); var content = (ListView)root.GetChildAt(0); root.RemoveAllViews(); result = (Toolbar)LayoutInflater.From(context).Inflate(layoutToolbarId, root, false); int height; var tv = new TypedValue(); if (context.Theme.ResolveAttribute(Android.Resource.Attribute.ActionBarSize, tv, true)) { height = TypedValue.ComplexToDimensionPixelSize(tv.Data, context.Resources.DisplayMetrics); } else { height = result.Height; } content.SetPadding(0, height, 0, 0); root.AddView(content); root.AddView(result); } return(result); }
public async Task <bool> ShowCheckboxDialogAsync(string title, string content, string checkboxTitle, string confirm = "Ok") { var activity = Xamarin.Essentials.Platform.CurrentActivity; TaskCompletionSource <bool> taskCompletionSource = new TaskCompletionSource <bool>(); LayoutInflater layoutInflater = LayoutInflater.From(activity); var view = layoutInflater.Inflate(Resource.Layout.CheckboxDialog, null); var cbxContent = view.FindViewById <TextView>(Resource.Id.cbxContent); cbxContent.Text = content; var cbxSkip = view.FindViewById <CheckBox>(Resource.Id.skip); cbxSkip.Text = checkboxTitle; var typedVal = new TypedValue(); if (activity.Theme.ResolveAttribute(Resource.Attribute.dialogPreferredPadding, typedVal, true)) { var padding = TypedValue.ComplexToDimensionPixelSize(typedVal.Data, activity.Resources.DisplayMetrics); cbxContent.SetPadding(0, padding / 2, 0, padding / 2); view.SetPadding(padding, 0, padding, 0); } var alert = new AlertDialog.Builder(activity, Resource.Style.AppTheme_AlertDialog) .SetTitle(title) .SetView(view) .SetCancelable(false) .SetPositiveButton(confirm, (sender, args) => { taskCompletionSource.TrySetResult(cbxSkip.Checked); }); alert.Show(); var res = await taskCompletionSource.Task; return(res); }
internal int GetActionBarHeight() { var attr = Resource.Attribute.actionBarSize; int actionBarHeight; using (var tv = new TypedValue()) { actionBarHeight = 0; if (_context.Theme.ResolveAttribute(attr, tv, true)) { actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, _context.Resources.DisplayMetrics); } } if (actionBarHeight <= 0) { return(IsPortrait() ? (int)_context.ToPixels(56) : (int)_context.ToPixels(48)); } return(actionBarHeight); }
protected void SetStatusBarTranslucent(bool makeTranslucent) { View v = FindViewById(Resource.Id.activity_failure); if (v != null) { int paddingTop = 0; TypedValue tv = new TypedValue(); Theme.ResolveAttribute(0, tv, true); paddingTop += TypedValue.ComplexToDimensionPixelSize(tv.Data, Resources.DisplayMetrics); v.SetPadding(0, makeTranslucent ? paddingTop : 0, 0, 0); } if (makeTranslucent) { Window.AddFlags(WindowManagerFlags.TranslucentStatus); } else { Window.ClearFlags(WindowManagerFlags.TranslucentStatus); } }
private void InitialMethod() { frame = new FrameLayout(con); totalHeight = con.Resources.DisplayMetrics.HeightPixels; TypedValue tv = new TypedValue(); if (con.Theme.ResolveAttribute(Android.Resource.Attribute.ActionBarSize, tv, true)) { actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, con.Resources.DisplayMetrics); } navigationBarHeight = getNavigationBarHeight(con); totalHeight = totalHeight - navigationBarHeight - actionBarHeight; //linearLayout linearLayout = new LinearLayout(con); linearLayout.SetPadding(20, 20, 20, 30); linearLayout.SetBackgroundColor(Color.White); linearLayout.LayoutParameters = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, (int)(totalHeight * 0.6), GravityFlags.Top | GravityFlags.CenterHorizontal); linearLayout.Orientation = Android.Widget.Orientation.Vertical; rangeHeight = getDimensionPixelSize(con, Resource.Dimension.range_ht); }
protected virtual void LoadView(IShellContext shellContext) { Profile.FrameBegin(); var context = shellContext.AndroidContext; var coordinator = (ViewGroup)LayoutInflater.FromContext(context).Inflate(Resource.Layout.flyoutcontent, null); Profile.FramePartition("Find AppBar"); _appBar = coordinator.FindViewById <AppBarLayout>(Resource.Id.flyoutcontent_appbar); _rootView = coordinator as ViewGroup; Profile.FramePartition("Add Listener"); _appBar.AddOnOffsetChangedListener(this); Profile.FramePartition("Add HeaderView"); _actionBarHeight = (int)context.ToPixels(56); UpdateFlyoutHeader(); UpdateFlyoutContent(); Profile.FramePartition("Initialize BgImage"); var metrics = context.Resources.DisplayMetrics; var width = Math.Min(metrics.WidthPixels, metrics.HeightPixels); using (TypedValue tv = new TypedValue()) { if (context.Theme.ResolveAttribute(global::Android.Resource.Attribute.ActionBarSize, tv, true)) { _actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, metrics); } } width -= _actionBarHeight; coordinator.LayoutParameters = new LP(width, LP.MatchParent); _bgImage = new ImageView(context) { LayoutParameters = new LP(coordinator.LayoutParameters) }; Profile.FramePartition("UpdateFlyoutHeaderBehavior"); UpdateFlyoutHeaderBehavior(); _shellContext.Shell.PropertyChanged += OnShellPropertyChanged; Profile.FramePartition("UpdateFlyoutBackground"); UpdateFlyoutBackground(); Profile.FramePartition(nameof(UpdateVerticalScrollMode)); UpdateVerticalScrollMode(); Profile.FramePartition("FlyoutFooter"); UpdateFlyoutFooter(); Profile.FrameEnd(); if (View is ShellFlyoutLayout sfl) { sfl.LayoutChanging += OnFlyoutViewLayoutChanged; } }
protected virtual void LoadView(IShellContext shellContext) { Profile.FrameBegin(); var context = shellContext.AndroidContext; // Android designer can't load fragments or resources from layouts if (context.IsDesignerContext()) { _rootView = new FrameLayout(context); return; } var coordinator = LayoutInflater.FromContext(context).Inflate(Resource.Layout.FlyoutContent, null); Profile.FramePartition("Find Recycler"); _recycler = coordinator.FindViewById <RecyclerView>(Resource.Id.flyoutcontent_recycler); Profile.FramePartition("Find AppBar"); _appBar = coordinator.FindViewById <AppBarLayout>(Resource.Id.flyoutcontent_appbar); _rootView = coordinator as ViewGroup; Profile.FramePartition("Add Listener"); _appBar.AddOnOffsetChangedListener(this); Profile.FramePartition("Add HeaderView"); _actionBarHeight = (int)context.ToPixels(56); UpdateFlyoutHeader(); Profile.FramePartition("Recycler.SetAdapter"); _adapter = new ShellFlyoutRecyclerAdapter(shellContext, OnElementSelected); _recycler.SetClipToPadding(false); _recycler.SetLayoutManager(_layoutManager = new ScrollLayoutManager(context, (int)Orientation.Vertical, false)); _recycler.SetLayoutManager(new LinearLayoutManager(context, (int)Orientation.Vertical, false)); _recycler.SetAdapter(_adapter); Profile.FramePartition("Initialize BgImage"); var metrics = context.Resources.DisplayMetrics; var width = Math.Min(metrics.WidthPixels, metrics.HeightPixels); using (TypedValue tv = new TypedValue()) { if (context.Theme.ResolveAttribute(global::Android.Resource.Attribute.ActionBarSize, tv, true)) { _actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, metrics); } } width -= _actionBarHeight; coordinator.LayoutParameters = new LP(width, LP.MatchParent); _bgImage = new ImageView(context) { LayoutParameters = new LP(coordinator.LayoutParameters) }; Profile.FramePartition("UpdateFlyoutHeaderBehavior"); UpdateFlyoutHeaderBehavior(); _shellContext.Shell.PropertyChanged += OnShellPropertyChanged; Profile.FramePartition("UpdateFlyoutBackground"); UpdateFlyoutBackground(); Profile.FramePartition(nameof(UpdateVerticalScrollMode)); UpdateVerticalScrollMode(); Profile.FrameEnd(); }
public static Int32 GetAttributePixelSize(Context context, Int32 attributeId) { Int32 value = GetAttribute(context, attributeId); return(TypedValue.ComplexToDimensionPixelSize(value, context.Resources.DisplayMetrics)); }