2

我有一个 textView 我试图在运行时更改大小。但大小不会改变。

xml文件中的代码

 <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 上的代码以更改大小

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

大小不变

4

1 回答 1

2

用这个:

t.getLayoutParams().width = 950;

于 2013-03-03T19:41:27.933 回答