public void SetStacked(bool stacked, bool force) { if (_stacked != stacked || force) { Gravity = stacked ? GravityFlags.CenterVertical | GravityExt.GetGravity(_stackedGravity) : GravityFlags.Center; if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBeanMr1) { TextAlignment = stacked ? TextAlignment.Gravity : TextAlignment.Center; } DialogUtils.SetBackgroundCompat(this, stacked ? _stackedBackground : _defaultBackground); if (stacked) { SetPadding(_stackedEndPadding, PaddingTop, _stackedEndPadding, PaddingBottom); } _stacked = stacked; } }
private void SetupGravity(ViewGroup view) { LinearLayout itemRoot = (LinearLayout)view; GravityFlags gravity = GravityExt.GetGravity(dialog.MBuilder.ItemsGravity); itemRoot.SetGravity(gravity | GravityFlags.CenterVertical); if (view.ChildCount == 2) { if (dialog.MBuilder.ItemsGravity == GravityEnum.End && !IsRtl() && view.GetChildAt(0) is ImageView) { CompoundButton first = (CompoundButton)view.GetChildAt(0); view.RemoveView(first); TextView second = (TextView)view.GetChildAt(0); view.RemoveView(first); second.SetPadding(second.PaddingRight, second.PaddingTop, second.PaddingLeft, second.PaddingBottom); view.AddView(second); view.AddView(first); } } else if (dialog.MBuilder.ItemsGravity == GravityEnum.Start && IsRtl() && view.GetChildAt(1) is ImageView) { CompoundButton first = (CompoundButton)view.GetChildAt(1); view.RemoveView(first); TextView second = (TextView)view.GetChildAt(0); view.RemoveView(second); second.SetPadding(second.PaddingRight, second.PaddingTop, second.PaddingRight, second.PaddingBottom); view.AddView(first); view.AddView(second); } }