private RadioButton createRadioView() { RadioButton mRadioButton = new RadioButton(getContext(), null, mRadioStyle > 0 ? mRadioStyle : android.R.attr.radioButtonStyle); if (mRadioStyle == 0) { mRadioButton.setGravity(Gravity.CENTER); mRadioButton.setEllipsize(TruncateAt.END); } if (mTextColor != null) mRadioButton.setTextColor(mTextColor); if (textSize > 0) mRadioButton.setTextSize(textSize); return mRadioButton; }
rb.setOnCheckedChangeListener(this); rb.setText(label); rb.setTextSize(mAnswerFontsize); mButtons.addView(rb);
RadioButton r = new RadioButton(getContext()); r.setText(prompt.getSelectChoiceText(mItems.get(i))); r.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize); r.setTag(Integer.valueOf(i)); r.setId(QuestionWidget.newUniqueId());
r.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize); r.setTag(Integer.valueOf(i)); r.setId(QuestionWidget.newUniqueId());
/** * 创建子 tab * * @param context * @param id */ public static RadioButton creatTabItem(Context context, int id, String text) { final int width = DensityUtil.dip2px(context, 80); final int height = DensityUtil.dip2px(context, 46); final int padding = DensityUtil.dip2px(context, 3); RadioButton button; button = new RadioButton(context); button.setId(id); // button.setWidth(width); // button.setHeight(height); button.setText(text); button.setLayoutParams(new LinearLayout.LayoutParams(width, height)); button.setHeight(height); button.setBackgroundResource(R.drawable.tab_item_bg_selector); button.setButtonDrawable(context.getResources().getDrawable(android.R.color.transparent)); button.setGravity(Gravity.CENTER); button.setTextColor(context.getResources().getColorStateList(R.color.tab_item_font_color_selector)); button.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); button.setPadding(0, 0, 0, padding); return button; } }
newRadioButton.setTextSize(mEntriesTextSize); newRadioButton.setPadding(mEntriesSidesPadding, mEntriesUpDownRadioPadding, mEntriesSidesPadding,
@Override RadioGroup createWidgetView(AppCompatActivity activity) { radioGroup = new RadioGroup(activity); radioGroup.setPadding(16, 16, 16, 16); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); layoutParams.topMargin = 32; layoutParams.bottomMargin = 32; String[] values = getInputValues(activity.getIntent()); for (int j = 0; j < values.length; ++j) { String value = values[j]; RadioButton button = new RadioButton(activity); button.setText(value); button.setId(j); button.setTextSize(18); button.setPadding(16, 16, 16, 16); button.setLayoutParams(layoutParams); radioGroup.addView(button); } return radioGroup; }
private void createRadioGroup() { final LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); if (mRadioGroup == null) { mRadioGroup = new RadioGroup(mContext); mRadioGroup.setLayoutParams(params); } else { removeView(mRadioGroup); } mRadioGroup.removeAllViews(); mRadioGroup.setOnCheckedChangeListener(this); for (ODataRow label : items) { RadioButton rdoBtn = new RadioButton(mContext); rdoBtn.setLayoutParams(params); rdoBtn.setText(label.getString(mModel.getDefaultNameColumn())); if (textSize > -1) { rdoBtn.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); } if (appearance > -1) { rdoBtn.setTextAppearance(mContext, appearance); } rdoBtn.setTextColor(textColor); mRadioGroup.addView(rdoBtn); } addView(mRadioGroup); }