androidtextviewgradientdrawable

GradientDrawable border textview croped


As you can see on the picture below, I put a GradientDrawable as background of a textview.

The result is weird : the text is croped.

Result

And there is the code :

GradientDrawable border = new GradientDrawable();
    border.setColor(0x00FFFFFF);
    border.setStroke(1,Color.GRAY);
    border.setCornerRadius(size);

    EditText surname = new EditText(this);
    surname.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM);
    surname.setBackground(border);
    surname.setTypeface(Stats.fontRegular);
    FrameLayout.LayoutParams lps = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, size_x);
    surname.setLayoutParams(lps);
    view.addView(surname);

If you know a way to uncrop the text it will be very usefull for me :)


Solution

  • I found something that works :

    When you use a EditText, it seems that there are some paddings inside the view. So you can 'disable' them using

    EditText.setPadding(int left, int top, int right, int bottom)