My current simple XML is below, however i would like the 3 TextViews within it to be circular, rather than rectangular.
How can I change my code to do so?
It's a rectangle that prevents oval shape background to get circular.
Making view a square will fix everything.
I found this solution to be clean and working for varying textsize and text length.
public class EqualWidthHeightTextView extends TextView {
public EqualWidthHeightTextView(Context context) {
super(context);
}
public EqualWidthHeightTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public EqualWidthHeightTextView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int r = Math.max(getMeasuredWidth(),getMeasuredHeight());
setMeasuredDimension(r, r);
}
}
Usage
oval_light_blue_bg.xml
android:shape="oval">