protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; //スプラッシュ画面の設定 base.Window.RequestFeature(WindowFeatures.ActionBar); base.SetTheme(Resource.Style.MainTheme); base.OnCreate(savedInstanceState); base.SetTheme(Resource.Style.MainTheme); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); OxyPlot.Xamarin.Forms.Platform.Android.PlotViewRenderer.Init(); // プログレスバー(ダウンロード、アップロード時) // 呼び出し方 // 表示 => MessagingCenter.Send(App, "dialog_progress",true); // 非表示 => MessagingCenter.Send(App, "dialog_progress", false); AlertDialog alertDialog = null; MessagingCenter.Subscribe <LinkPage, bool>(this, "dialog_progress", (page, isVisible) => { if (alertDialog != null) { alertDialog.Dismiss(); alertDialog = null; } if (isVisible) { var progress = new Android.Widget.ProgressBar(this); progress.SetPadding(0, 30, 0, 30); alertDialog = new AlertDialog.Builder(this) .SetTitle("データ連携中です。") .SetView(progress) .SetCancelable(false) .Show(); } }); LoadApplication(new App()); }
public LoadingOverlay(Context context, bool withoutSpinner = false, PriceGrabber.CustomControls.Orientation orientation = PriceGrabber.CustomControls.Orientation.Portrait) : base(context) { Color mainColor = Color.LightBlue; try { mainColor = ((Xamarin.Forms.Color)Xamarin.Forms.Application.Current.Resources["LightBlue"]).ToAndroid(); } catch { } this.Alpha = 0.75f; this.SetBackgroundColor(mainColor); var contentHeight = (int)StaticDeviceInfo.Height; var contentWidth = (int)StaticDeviceInfo.Width; if (orientation == PriceGrabber.CustomControls.Orientation.Landscape) { contentHeight = contentHeight + contentWidth; contentWidth = contentHeight - contentWidth; contentHeight = contentHeight - contentWidth; } // SetMinimumWidth(contentWidth); //SetMinimumHeight(contentHeight); this.LayoutParameters = new ViewGroup.LayoutParams(-1, -1); LayoutParams lp; image = new ImageView(this.Context); // image.SetImageResource(Resource.Drawable.insigniaStar); image.SetMinimumHeight(contentHeight / 2); image.SetMinimumWidth(contentWidth / 2); lp = new LayoutParams(contentHeight / 2, contentWidth / 2); lp.AddRule(LayoutRules.CenterInParent); AddView(image, lp); spinner = new ProgressBar(this.Context); if (Build.VERSION.SdkInt >= BuildVersionCodes.M) { spinner.SetForegroundGravity(GravityFlags.CenterVertical | GravityFlags.CenterHorizontal); } spinner.SetMinimumWidth(100); spinner.SetPadding(0, 0, 0, 50); spinner.IndeterminateDrawable.SetColorFilter(Color.White, PorterDuff.Mode.SrcIn); lp = new LayoutParams(100, 150); lp.AddRule(LayoutRules.CenterInParent); /*ViewGroup.LayoutParams vlp = new ViewGroup.LayoutParams( * ViewGroup.LayoutParams.MatchParent, * ViewGroup.LayoutParams.MatchParent);*/ if (!withoutSpinner && spinner.Parent == null) { AddView(spinner, lp); } label = new TextView(this.Context); // { Text = HPHData.LocalizableText("Loading data") }; label.Gravity = GravityFlags.Center; label.SetPadding(0, 100, 0, 0); label.SetTextColor(Color.White); label.SetText("Loading data", TextView.BufferType.Normal); try { var tf = Typeface.CreateFromAsset(MainActivity.Instance.Assets, "HPSimplified_Lt.ttf"); label.SetTypeface(tf, TypefaceStyle.Normal); } catch { } lp = new LayoutParams(300, 150); lp.AddRule(LayoutRules.CenterInParent); if (!withoutSpinner && label.Parent == null) { AddView(label, lp); } }