I have a vertical LinearLayout
with two TextView
inside it. The former contains a static text property (it\'s text never change) and the last conta
Make baseline of the text equal to the bottom of the TextView.
public class BaselineTextView extends TextView {
public BaselineTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onDraw(Canvas canvas) {
int yOffset = getHeight() - getBaseline();
canvas.translate(0, yOffset);
super.onDraw(canvas);
}
}
NOTE: To avoid chopping off descenders call setClipChildren(false)
on your TextView
's parent ViewGroup
(android:clipChildren="false"
in XML).