2011-05-25 259 views
2

如何使用java代碼減少android中的單選按鈕大小?這個太大了。android中的單選按鈕大小

我正在使用的代碼:

deal = new RadioButton(context); 
deal.setHeight(10); 
deal.setWidth(5); 

這是不是有效的。請建議。

回答

1

る創建單選按鈕dynamically.then,而不是使用自動調用setHeight和setwidth方法U設置高度和寬度也使用layoutparams.set佈局參數中的寬度和高度...下面給出的是按鈕參數的示例。

addQuestion.setId(134); 
    addQuestion.setTag("addQuestion"); 
    addQuestion.setBackgroundDrawable(getResources().getDrawable(R.drawable.add_button)); 
    addQuestion.setGravity(Gravity.LEFT); 
    LinearLayout.LayoutParams addQuestion_Params = 
     new LinearLayout.LayoutParams(24, 24); 
    addQuestion_Params.leftMargin=20; 
    addQuestion.setOnClickListener(mirScreenClickListener); 
    questionAndAddButtonContainer.addView(addQuestion, addQuestion_Params); 
+0

我使用param.topMargin = 20;但它沒有改變單選按鈕之間的差距。哪裏不對了?謝謝。 – herbertD 2012-08-29 06:45:55