安卓:试图改变TextView的宽度在运行时

问题描述:

我有一个TextView我试图改变大小在运行时。但大小不chnage

I have a textView that I'm trying to change the size at runtime. But the size does not chnage.

在code在XML文件

The code in the xml file

 <TextView
                android:id="@+id/textScreenWidth"
                android:layout_width="100px"
                android:layout_height="wrap_content"
                android:text=""
                android:layout_gravity="center"
                android:textColor="#ff000000"
                android:textStyle="bold"
                android:textSize="12dp"

在OnCreat code来改变大小

code on OnCreat to change the the size

TextView t=(TextView) findViewById(R.id.textScreenWidth); 
    t.setWidth(950);

的大小不改变

the size does not change

使用这样的:

t.getLayoutParams()宽度= 950;