安卓:试图改变TextView的宽度在运行时 [英] Android: Trying to change width of TextView at runtime

查看:109
本文介绍了安卓:试图改变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;

这篇关于安卓:试图改变TextView的宽度在运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆