Try adding LayoutParams
and MaxWidth
and MaxHeight
to the TextView
. It will force the layout to respect the parent container and not overflow.
textview.setLayoutParams(new LayoutParams(LinearLayout.MATCH_PARENT,LinearLayout.WRAP_CONTENT));
int GeneralApproxWidthOfContainer = 400;
int GeneralApproxHeightOfContainer = 600;
textview.setMaxWidth(400);
textview.setMaxHeight(600);`