You want to use the method setLayoutParams
of TextView and pass into it a new LinearLayout.LayoutParams(width, height)
where width and height are integers that will specify the width and height. you can keep the height and set the width to whatever you want.