我正在尝试动态设置TextView的宽度,使用setWidth(width)
方法。
txtviewOne.setWidth(10);
txtviewTwo.setWidth(10);
但是没有成功。
请帮我,如何动态设置TextView的宽度。
我正在尝试动态设置TextView的宽度,使用setWidth(width)
方法。
txtviewOne.setWidth(10);
txtviewTwo.setWidth(10);
但是没有成功。
请帮我,如何动态设置TextView的宽度。
TextView tv;
----------------------
tv=new TextView(this); // or tv=new TextView(R.id.textview1);
LinearLayout.LayoutParams Params1 = new LinearLayout.LayoutParams(15,50);
tv.setLayoutParams(Params1);
new TableRow()
,因为textView的父视图是TableRow
。如果你的父视图是LinearLayout
,请用new LinearLayout.LayoutParams
替换它。textView.setLayoutParams(
new TableRow.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.MATCH_PARENT));