Java Code Examples for android.view.Gravity#END

The following examples show how to use android.view.Gravity#END . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NoboButton.java    From NoboButton with Apache License 2.0 6 votes vote down vote up
private void updateGravity() {
	if (lGravity == GRAVITY_CENTER) {
		// center
		super.setGravity(Gravity.CENTER);
	} else if (lGravity == GRAVITY_LEFT) {
		// left
		super.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
	} else if (lGravity == GRAVITY_RIGHT) {
		// right
		super.setGravity(Gravity.END | Gravity.CENTER_VERTICAL);
	} else if (lGravity == GRAVITY_TOP) {
		// top
		super.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
	} else if (lGravity == GRAVITY_BOTTOM) {
		// bottom
		super.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
	}
}
 
Example 2
Source File: SatelliteMenuView.java    From CrazyDaily with Apache License 2.0 6 votes vote down vote up
public void setImgRes(ImgResEntity entity) {
    final Context context = getContext();
    final int dp_6 = dp2px(context, 6);
    final int dp_3 = dp2px(context, 3);
    FloatingActionButton fab = new FloatingActionButton(context);
    fab.setPadding(dp_6, dp_6, dp_6, dp_6);
    fab.setElevation(dp_3);
    fab.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    fab.setSize(FloatingActionButton.SIZE_MINI);
    fab.setBackgroundTintList(ColorStateList.valueOf(entity.color));
    fab.setImageResource(entity.res);
    fab.setUseCompatPadding(true);
    final int size = (int) (SIZE * BUTTON_RATIO);
    LayoutParams params = new LayoutParams(size, size);
    params.gravity = Gravity.END | Gravity.BOTTOM;
    addView(fab, params);
    mButtonView = fab;
    mButtonView.setOnClickListener(v -> {
        if (isOpen) {
            close();
        } else {
            show();
        }
    });
}
 
Example 3
Source File: GravitySnapHelper.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void attachToRecyclerView(@Nullable RecyclerView recyclerView)
        throws IllegalStateException {
    if (this.recyclerView != null) {
        this.recyclerView.removeOnScrollListener(scrollListener);
    }
    if (recyclerView != null) {
        recyclerView.setOnFlingListener(null);
        if (gravity == Gravity.START || gravity == Gravity.END) {
            isRtl = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault())
                    == ViewCompat.LAYOUT_DIRECTION_RTL;
        }
        recyclerView.addOnScrollListener(scrollListener);
        this.recyclerView = recyclerView;
    } else {
        this.recyclerView = null;
    }
    super.attachToRecyclerView(recyclerView);
}
 
Example 4
Source File: ITabView.java    From VerticalTabLayout with Apache License 2.0 6 votes vote down vote up
public Builder() {
    colorBackground = 0xFFE84E40;
    colorBadgeText = 0xFFFFFFFF;
    colorStroke = Color.TRANSPARENT;
    drawableBackground = null;
    drawableBackgroundClip = false;
    strokeWidth = 0;
    badgeTextSize = 11;
    badgePadding = 5;
    badgeNumber = 0;
    badgeText = null;
    badgeGravity = Gravity.END | Gravity.TOP;
    gravityOffsetX = 1;
    gravityOffsetY = 1;
    exactMode = false;
    showShadow = true;
}
 
Example 5
Source File: IndexableLayout.java    From IndexableRecyclerView with Apache License 2.0 6 votes vote down vote up
private void initMDOverlay(int color) {
    mMDOverlay = new AppCompatTextView(mContext);
    mMDOverlay.setBackgroundResource(R.drawable.indexable_bg_md_overlay);
    ((AppCompatTextView) mMDOverlay).setSupportBackgroundTintList(ColorStateList.valueOf(color));
    mMDOverlay.setSingleLine();
    mMDOverlay.setTextColor(Color.WHITE);
    mMDOverlay.setTextSize(38);
    mMDOverlay.setGravity(Gravity.CENTER);
    int size = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 72, getResources().getDisplayMetrics());
    LayoutParams params = new LayoutParams(size, size);
    params.rightMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 33, getResources().getDisplayMetrics());
    params.gravity = Gravity.END;
    mMDOverlay.setLayoutParams(params);
    mMDOverlay.setVisibility(INVISIBLE);

    addView(mMDOverlay);
}
 
Example 6
Source File: GravitySnapHelper.java    From date_picker_converter with Apache License 2.0 6 votes vote down vote up
@Override
public void attachToRecyclerView(@Nullable RecyclerView recyclerView)
        throws IllegalStateException {
    if (recyclerView != null) {
        if ((gravity == Gravity.START || gravity == Gravity.END)
                && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            isRtlHorizontal
                    = recyclerView.getContext().getResources().getConfiguration()
                    .getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
        }
        if (listener != null) {
            recyclerView.addOnScrollListener(mScrollListener);
        }
    }
    super.attachToRecyclerView(recyclerView);
}
 
Example 7
Source File: GravityDelegate.java    From GetApk with MIT License 6 votes vote down vote up
public View findSnapView(RecyclerView.LayoutManager layoutManager) {
    View snapView = null;
    if (layoutManager instanceof LinearLayoutManager) {
        switch (gravity) {
            case Gravity.START:
                snapView = findStartView(layoutManager, getHorizontalHelper(layoutManager));
                break;
            case Gravity.END:
                snapView = findEndView(layoutManager, getHorizontalHelper(layoutManager));
                break;
            case Gravity.TOP:
                snapView = findStartView(layoutManager, getVerticalHelper(layoutManager));
                break;
            case Gravity.BOTTOM:
                snapView = findEndView(layoutManager, getVerticalHelper(layoutManager));
                break;
        }
    }
    snapping = snapView != null;
    return snapView;
}
 
Example 8
Source File: EditTextSpec.java    From litho with Apache License 2.0 6 votes vote down vote up
private static Layout.Alignment getAlignment(int gravity) {
  final Layout.Alignment alignment;
  // This was copied from TextSpec for handling text alignment
  switch (gravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) {
    case Gravity.START:
      alignment = ALIGN_NORMAL;
      break;
    case Gravity.END:
      alignment = ALIGN_OPPOSITE;
      break;
    case Gravity.LEFT: // unsupported, default to normal
      alignment = ALIGN_NORMAL;
      break;
    case Gravity.RIGHT: // unsupported, default to opposite
      alignment = ALIGN_OPPOSITE;
      break;
    case Gravity.CENTER_HORIZONTAL:
      alignment = ALIGN_CENTER;
      break;
    default:
      alignment = textAlignment;
      break;
  }
  return alignment;
}
 
Example 9
Source File: QTabView.java    From VerticalTabLayout with Apache License 2.0 6 votes vote down vote up
private void initIconView() {
    int iconResid = mChecked ? mTabIcon.getSelectedIcon() : mTabIcon.getNormalIcon();
    Drawable drawable = null;
    if (iconResid != 0) {
        drawable = mContext.getResources().getDrawable(iconResid);
        int r = mTabIcon.getIconWidth() != -1 ? mTabIcon.getIconWidth() : drawable.getIntrinsicWidth();
        int b = mTabIcon.getIconHeight() != -1 ? mTabIcon.getIconHeight() : drawable.getIntrinsicHeight();
        drawable.setBounds(0, 0, r, b);
    }
    switch (mTabIcon.getIconGravity()) {
        case Gravity.START:
            mTitle.setCompoundDrawables(drawable, null, null, null);
            break;
        case Gravity.TOP:
            mTitle.setCompoundDrawables(null, drawable, null, null);
            break;
        case Gravity.END:
            mTitle.setCompoundDrawables(null, null, drawable, null);
            break;
        case Gravity.BOTTOM:
            mTitle.setCompoundDrawables(null, null, null, drawable);
            break;
    }
    refreshDrawablePadding();
}
 
Example 10
Source File: ScrollPageHelper.java    From YCRefreshView with Apache License 2.0 6 votes vote down vote up
@Override
public void attachToRecyclerView(@Nullable RecyclerView recyclerView)
        throws IllegalStateException {
    if (recyclerView != null && !(recyclerView.getLayoutManager()
            instanceof LinearLayoutManager)) {
        throw new IllegalStateException("ScrollPageHelper needs a " +
                "RecyclerView with a LinearLayoutManager");
    }
    if (recyclerView != null) {
        //设置fling监听为null
        recyclerView.setOnFlingListener(null);
        if ((gravity == Gravity.START || gravity == Gravity.END)) {
            isRtlHorizontal = isRtl();
        }
    }
    super.attachToRecyclerView(recyclerView);
}
 
Example 11
Source File: GravitySnapHelper.java    From date_picker_converter with Apache License 2.0 5 votes vote down vote up
public GravitySnapHelper(int gravity, SnapListener snapListener) {
    if (gravity != Gravity.START && gravity != Gravity.END
            && gravity != Gravity.BOTTOM && gravity != Gravity.TOP) {
        throw new IllegalArgumentException("Invalid gravity value. Use START " +
                "| END | BOTTOM | TOP constants");
    }
    this.gravity = gravity;
    this.listener = snapListener;
}
 
Example 12
Source File: BaseActivity.java    From SimpleAdapterDemo with Apache License 2.0 5 votes vote down vote up
@Override
    protected void initActionBar(ActionBar actionBar) {
        if (actionBar == null)
            return;

        int padding = CompatResourceUtils.getDimensionPixelSize(this, R.dimen.space_12);
        FrameLayout customView = new FrameLayout(this);
//        customView.setPadding(padding, 0, padding, 0);
        ActionBar.LayoutParams barParams = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, WindowUtils.getActionBarSize(this));
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setCustomView(customView, barParams);
        //添加标题
        tvTitle = new TextView(this);
        tvTitle.setTextColor(Color.WHITE);
        tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
        tvTitle.setGravity(Gravity.CENTER);
        customView.addView(tvTitle, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
        //添加返回按钮
        ivBack = new ImageView(this);
        ivBack.setPadding(padding / 2, 0, padding / 2, 0);
        ivBack.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        ivBack.setImageResource(R.drawable.ic_chevron_left_white_24dp);
        ivBack.setBackground(WindowUtils.getSelectableItemBackgroundBorderless(this));
        customView.addView(ivBack, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
        ivBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        //添加menu菜单
        actionMenuView = new ActionMenuView(this);
        FrameLayout.LayoutParams menuParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
        menuParams.gravity = Gravity.END | Gravity.CENTER_VERTICAL;
        customView.addView(actionMenuView, menuParams);
    }
 
Example 13
Source File: TitleBarView.java    From TitleBarView with Apache License 2.0 5 votes vote down vote up
/**
 * 根据位置获取TextView
 *
 * @param gravity 参考{@link Gravity}
 * @return
 */
public TextView getTextView(int gravity) {
    if (gravity == Gravity.LEFT || gravity == Gravity.START) {
        return mLeftTv;
    } else if (gravity == (Gravity.CENTER | Gravity.TOP)) {
        return mTitleMain;
    } else if (gravity == (Gravity.CENTER | Gravity.BOTTOM)) {
        return mTitleSub;
    } else if (gravity == Gravity.END || gravity == Gravity.RIGHT) {
        return mRightTv;
    }
    return mTitleMain;
}
 
Example 14
Source File: GravitySnapHelper.java    From GravitySnapHelper with Apache License 2.0 5 votes vote down vote up
@Override
@NonNull
public int[] calculateDistanceToFinalSnap(@NonNull RecyclerView.LayoutManager layoutManager,
                                          @NonNull View targetView) {
    if (gravity == Gravity.CENTER) {
        //noinspection ConstantConditions
        return super.calculateDistanceToFinalSnap(layoutManager, targetView);
    }

    int[] out = new int[2];

    if (!(layoutManager instanceof LinearLayoutManager)) {
        return out;
    }

    LinearLayoutManager lm = (LinearLayoutManager) layoutManager;

    if (lm.canScrollHorizontally()) {
        if ((isRtl && gravity == Gravity.END) || (!isRtl && gravity == Gravity.START)) {
            out[0] = getDistanceToStart(targetView, getHorizontalHelper(lm));
        } else {
            out[0] = getDistanceToEnd(targetView, getHorizontalHelper(lm));
        }
    } else if (lm.canScrollVertically()) {
        if (gravity == Gravity.TOP) {
            out[1] = getDistanceToStart(targetView, getVerticalHelper(lm));
        } else {
            out[1] = getDistanceToEnd(targetView, getVerticalHelper(lm));
        }
    }
    return out;
}
 
Example 15
Source File: GiraffePlayer.java    From GiraffePlayer2 with Apache License 2.0 4 votes vote down vote up
private ViewGroup createFloatBox() {
        removeFloatContainer();
        Activity topActivity = PlayerManager.getInstance().getTopActivity();
        ViewGroup topActivityBox = (ViewGroup) topActivity.findViewById(android.R.id.content);
        ViewGroup floatBox = (ViewGroup) LayoutInflater.from(topActivity.getApplication()).inflate(R.layout.giraffe_float_box, null);
        floatBox.setBackgroundColor(videoInfo.getBgColor());

        FrameLayout.LayoutParams floatBoxParams = new FrameLayout.LayoutParams(VideoInfo.floatView_width, VideoInfo.floatView_height);
        if (VideoInfo.floatView_x == Integer.MAX_VALUE || VideoInfo.floatView_y == Integer.MAX_VALUE) {
            floatBoxParams.gravity = Gravity.BOTTOM | Gravity.END;
            floatBoxParams.bottomMargin = 20;
            floatBoxParams.rightMargin = 20;
        } else {
            floatBoxParams.gravity = Gravity.TOP | Gravity.START;
            floatBoxParams.leftMargin = (int) VideoInfo.floatView_x;
            floatBoxParams.topMargin = (int) VideoInfo.floatView_y;
        }
        topActivityBox.addView(floatBox, floatBoxParams);

        floatBox.setOnTouchListener(new View.OnTouchListener() {
            float ry;
            float oy;

            float rx;
            float ox;

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                // 获取相对屏幕的坐标,即以屏幕左上角为原点
//                System.out.println("MotionEvent:action:"+event.getAction()+",raw:["+event.getRawX()+","+event.getRawY()+"],xy["+event.getX()+","+event.getY()+"]");

                switch (event.getAction()) {
                    case MotionEvent.ACTION_DOWN:
                        ry = event.getRawY();
                        oy = v.getTranslationY();

                        rx = event.getRawX();
                        ox = v.getTranslationX();
                        break;
                    case MotionEvent.ACTION_MOVE:
                        float y = oy + event.getRawY() - ry;
                        if (y > 0) {
//                            y = 0;
                        }
                        v.setTranslationY(y);

                        float x = ox + event.getRawX() - rx;
                        if (x > 0) {
//                            x = 0;
                        }
                        v.setTranslationX(x);
                        break;
                }
                return true;
            }
        });
        return floatBox;
    }
 
Example 16
Source File: FooterLayout.java    From Expert-Android-Programming with MIT License 4 votes vote down vote up
private int getGravity(int gravityEnum) {
    return (gravityEnum == 0 ? Gravity.START
            : gravityEnum == 1 ? Gravity.CENTER_HORIZONTAL : Gravity.END) | Gravity.CENTER_VERTICAL;
}
 
Example 17
Source File: TLabel.java    From Tehreer-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Sets the horizontal alignment of the text and the vertical gravity that will be used when
 * there is extra space in the Label beyond what is required for the text itself.
 *
 * @param gravity The horizontal and vertical alignment.
 */
public void setGravity(int gravity) {
    mGravity = gravity;

    int horizontalGravity = mGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK;
    int verticalGravity = mGravity & Gravity.VERTICAL_GRAVITY_MASK;

    TextAlignment textAlignment;
    VerticalAlignment verticalAlignment;

    // Resolve horizontal gravity.
    switch (horizontalGravity) {
    case Gravity.LEFT:
        textAlignment = TextAlignment.LEFT;
        break;

    case Gravity.RIGHT:
        textAlignment = TextAlignment.RIGHT;
        break;

    case Gravity.CENTER_HORIZONTAL:
        textAlignment = TextAlignment.CENTER;
        break;

    case Gravity.END:
        textAlignment = TextAlignment.EXTRINSIC;
        break;

    default:
        textAlignment = TextAlignment.INTRINSIC;
        break;
    }

    // Resolve vertical gravity.
    switch (verticalGravity) {
    case Gravity.TOP:
        verticalAlignment = VerticalAlignment.TOP;
        break;

    case Gravity.BOTTOM:
        verticalAlignment = VerticalAlignment.BOTTOM;
        break;

    default:
        verticalAlignment = VerticalAlignment.MIDDLE;
        break;
    }

    mResolver.setTextAlignment(textAlignment);
    mResolver.setVerticalAlignment(verticalAlignment);

    requestLayout();
    invalidate();
}
 
Example 18
Source File: EmptyFragmentActivity.java    From SimpleAdapterDemo with Apache License 2.0 4 votes vote down vote up
@Override
    public void initActionBar(ActionBar actionBar) {
        if (actionBar == null)
            return;

        //You can initialize custom action bar here.
        int padding = CompatResourceUtils.getDimensionPixelSize(this, R.dimen.space_12);
        FrameLayout customView = new FrameLayout(this);
//        customView.setPadding(padding, 0, padding, 0);
        ActionBar.LayoutParams barParams = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, WindowUtils.getActionBarSize(this));
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setCustomView(customView, barParams);
        //添加标题
        TextView tvTitle = new TextView(this);
        tvTitle.setTextColor(Color.WHITE);
        tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
        tvTitle.setGravity(Gravity.CENTER);
        tvTitle.setText(getClass().getSimpleName().replace("Activity", ""));
        customView.addView(tvTitle, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
        //添加返回按钮
        ImageView ivBack = new ImageView(this);
        ivBack.setPadding(padding / 2, 0, padding / 2, 0);
        ivBack.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        ivBack.setImageResource(R.drawable.ic_chevron_left_white_24dp);
        ivBack.setBackground(WindowUtils.getSelectableItemBackgroundBorderless(this));
        customView.addView(ivBack, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
        ivBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        //添加menu菜单
        ActionMenuView actionMenuView = new ActionMenuView(this);
        FrameLayout.LayoutParams menuParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
        menuParams.gravity = Gravity.END | Gravity.CENTER_VERTICAL;
        customView.addView(actionMenuView, menuParams);

        String title = getIntent().getStringExtra(EXTRA_TITLE);
        tvTitle.setText(TextUtils.isEmpty(title) ? getClass().getSimpleName().replace("Activity", "") : title);
    }
 
Example 19
Source File: IconLabelItem.java    From openlauncher with Apache License 2.0 4 votes vote down vote up
@Override
public void bindView(@NonNull ViewHolder holder, @NonNull List<Object> payloads) {
    if (_width == Integer.MAX_VALUE) {
        holder.itemView.getLayoutParams().width = RecyclerView.LayoutParams.MATCH_PARENT;
    } else {
        holder.itemView.getLayoutParams().width = _width;
    }

    if (_height == Integer.MAX_VALUE) {
        holder.itemView.getLayoutParams().height = RecyclerView.LayoutParams.WRAP_CONTENT;
    } else {
        holder.itemView.getLayoutParams().height = _height;
    }

    // only run all this code if a label should be shown
    if (_label != null && _textVisibility) {
        holder.textView.setText(_label);
        holder.textView.setGravity(_textGravity);
        holder.textView.setMaxLines(1);
        holder.textView.setEllipsize(TextUtils.TruncateAt.END);
        // no default text color since it will be set by the theme
        if (_textColor != Integer.MAX_VALUE)
            holder.textView.setTextColor(_textColor);
    }

    // icon specific padding
    holder.textView.setCompoundDrawablePadding(_iconPadding);
    if (_iconSize != Integer.MAX_VALUE) {
        _icon = new BitmapDrawable(Setup.appContext().getResources(), Bitmap.createScaledBitmap(Tool.drawableToBitmap(_icon), _iconSize, _iconSize, true));
        _icon.setColorFilter(_iconColor, PorterDuff.Mode.SRC_ATOP);
        if (_isAppLauncher) {
            _icon.setBounds(0, 0, _iconSize, _iconSize);
        }
    }

    switch (_iconGravity) {
        case Gravity.START:
            if (_isAppLauncher) {
                holder.textView.setCompoundDrawables(_icon, null, null, null);
            } else {
                holder.textView.setCompoundDrawablesWithIntrinsicBounds(_icon, null, null, null);
            }
            break;
        case Gravity.END:
            if (_isAppLauncher) {
                holder.textView.setCompoundDrawables(null, null, _icon, null);
            } else {
                holder.textView.setCompoundDrawablesWithIntrinsicBounds(null, null, _icon, null);
            }
            break;
        case Gravity.TOP:
            if (_isAppLauncher) {
                holder.textView.setCompoundDrawables(null, _icon, null, null);
            } else {
                holder.textView.setCompoundDrawablesWithIntrinsicBounds(null, _icon, null, null);
            }
            break;
        case Gravity.BOTTOM:
            if (_isAppLauncher) {
                holder.textView.setCompoundDrawables(null, null, null, _icon);
            } else {
                holder.textView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, _icon);
            }
            break;
    }

    // most items will not use a long click
    if (!_onClickAnimate)
        holder.itemView.setBackgroundResource(0);
    if (_onClickListener != null)
        holder.itemView.setOnClickListener(_onClickListener);
    if (_onLongClickListener != null)
        holder.itemView.setOnLongClickListener(_onLongClickListener);

    super.bindView(holder, payloads);
}
 
Example 20
Source File: ArcNavigationView.java    From ArcNavigationView with Apache License 2.0 4 votes vote down vote up
@SuppressLint("RtlHardcoded")
private Path createClipPath() {
    final Path path = new Path();
    arcPath = new Path();

    float arcWidth = settings.getArcWidth();
    DrawerLayout.LayoutParams layoutParams = (DrawerLayout.LayoutParams) getLayoutParams();
    if (settings.isCropInside()) {
        if (layoutParams.gravity == Gravity.START || layoutParams.gravity == Gravity.LEFT) {
            arcPath.moveTo(width, 0);
            arcPath.quadTo(width - arcWidth, height / 2.0f,
                    width, height);
            arcPath.close();

            path.moveTo(0, 0);
            path.lineTo(width, 0);
            path.quadTo(width - arcWidth, height / 2.0f,
                    width, height);
            path.lineTo(0, height);
            path.close();
        } else if (layoutParams.gravity == Gravity.END || layoutParams.gravity == Gravity.RIGHT) {
            arcPath.moveTo(0, 0);
            arcPath.quadTo(arcWidth, height / 2.0f,
                    0, height);
            arcPath.close();

            path.moveTo(width, 0);
            path.lineTo(0, 0);
            path.quadTo(arcWidth, height / 2.0f,
                    0, height);
            path.lineTo(width, height);
            path.close();
        }
    } else {
        if (layoutParams.gravity == Gravity.START || layoutParams.gravity == Gravity.LEFT) {
            arcPath.moveTo(width - arcWidth / 2, 0);
            arcPath.quadTo(width + arcWidth / 2, height / 2.0f,
                    width - arcWidth / 2, height);
            arcPath.close();

            path.moveTo(0, 0);
            path.lineTo(width - arcWidth / 2, 0);
            path.quadTo(width + arcWidth / 2, height / 2.0f,
                    width - arcWidth / 2, height);
            path.lineTo(0, height);
            path.close();
        } else if (layoutParams.gravity == Gravity.END || layoutParams.gravity == Gravity.RIGHT) {
            arcPath.moveTo(arcWidth / 2, 0);
            arcPath.quadTo(-arcWidth / 2, height / 2.0f,
                    arcWidth / 2, height);
            arcPath.close();

            path.moveTo(width, 0);
            path.lineTo(arcWidth / 2, 0);
            path.quadTo(-arcWidth / 2, height / 2.0f,
                    arcWidth / 2, height);
            path.lineTo(width, height);
            path.close();
        }
    }
    return path;
}