【发布时间】:2011-12-28 23:41:38
【问题描述】:
我正在尝试将一堆按钮添加到这样的布局中:
for( int i = 0; i < 10; i++ ) {
Button button = new Button( this );
button.setText( "" + i );
( ( LinearLayout )dialog.findViewById( R.id.Buttons ) ).addView( button );
}
我的问题是如何以编程方式对所有按钮执行此操作:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textSize="32dip" />
我一直在查看 LayoutParams,但它看起来并不完整。比如如何将 textSize 设置为 32 dip?
【问题讨论】: