예제 #1
0
        AView CreateSwipeItem(SwipeItem formsSwipeItem)
        {
            var swipeButton = new AButton(_context)
            {
                Background = new ColorDrawable(formsSwipeItem.BackgroundColor.ToAndroid()),
                Text       = formsSwipeItem.Text
            };

            var textColor = GetSwipeItemColor(formsSwipeItem.BackgroundColor);

            swipeButton.SetTextColor(textColor.ToAndroid());
            swipeButton.TextAlignment = ATextAlignment.Center;

            int contentHeight = _contentView.Height;
            int contentWidth  = (int)_context.ToPixels(SwipeItemWidth);
            int iconSize      = Math.Min(contentHeight, contentWidth) / 2;

            _ = this.ApplyDrawableAsync(formsSwipeItem, MenuItem.IconImageSourceProperty, Context, drawable =>
            {
                drawable.SetBounds(0, 0, iconSize, iconSize);
                drawable.SetColorFilter(textColor.ToAndroid(), PorterDuff.Mode.SrcAtop);
                swipeButton.SetCompoundDrawables(null, drawable, null, null);
            });

            var textSize      = (int)swipeButton.TextSize;
            var buttonPadding = (contentHeight - (iconSize + textSize + 6)) / 2;

            swipeButton.SetPadding(0, buttonPadding, 0, buttonPadding);
            swipeButton.SetOnTouchListener(null);

            return(swipeButton);
        }
예제 #2
0
        void InitControls()
        {
            //Layout
            frame = new FrameLayout(Context);
            frame.LayoutParameters = new FrameLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
            nButton = new Android.Support.V7.Widget.AppCompatButton(Context);
            //Button
            var nBtnLayout = new FrameLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);

            nBtnLayout.SetMargins(8, 8, 8, 24);
            nButton.SetPadding(0, 0, 0, 0);
            nButton.LayoutParameters = nBtnLayout;
        }