android设置控件属性 新玩法
有时候,你需要在代码里设置某个控件的属性,但是呢,有些属性并不是很好设置,怎么办?
先在xml中设置一个相同的控件的属性,把其属性设置为隐藏,然后在外面获取
LayoutParams mLayoutParams = ((TextView)findViewById(R.id.img)).getLayoutParams();
接着,textView.setLayoutParams(mLayoutParams);即可。
有时候,你需要在代码里设置某个控件的属性,但是呢,有些属性并不是很好设置,怎么办?
先在xml中设置一个相同的控件的属性,把其属性设置为隐藏,然后在外面获取
LayoutParams mLayoutParams = ((TextView)findViewById(R.id.img)).getLayoutParams();
接着,textView.setLayoutParams(mLayoutParams);即可。