Java Code Examples for android.widget.RadioButton#setLayoutParams()
The following examples show how to use
android.widget.RadioButton#setLayoutParams() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BannerView.java From MvpRoute with Apache License 2.0 | 6 votes |
@NonNull private RadioButton initData(int length, int i, Object imagepath) { initImageView(i, imagepath); RadioButton radioButton = new RadioButton(context); if (selectTab != 0) { radioButton.setBackgroundResource(selectTab); radioButton.setButtonDrawable(context.getResources().getDrawable(android.R.color.transparent)); } RadioGroup.LayoutParams buttonParams = new RadioGroup.LayoutParams(tabWidth, tabHeight); if (i != length - 1) { buttonParams.setMargins(0, 0, tabMargin, 0); } radioButton.setLayoutParams(buttonParams); radioButton.setId(i); if (i == 0) radioButton.setChecked(true); return radioButton; }
Example 2
Source File: WizardFragment.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
private void createRadioButtons() { // set button dimension int buttonSize = AptoideUtils.ScreenU.getPixelsForDip(10, getResources()); ViewGroup.LayoutParams buttonLayoutParams = new RadioGroup.LayoutParams(buttonSize, buttonSize); // set button margin int buttonMargin = AptoideUtils.ScreenU.getPixelsForDip(2, getResources()); ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) buttonLayoutParams; marginLayoutParams.setMargins(buttonMargin, buttonMargin, buttonMargin, buttonMargin); final int pages = viewPagerAdapter.getCount(); wizardButtons = new ArrayList<>(pages); Context context = getContext(); for (int i = 0; i < pages; i++) { RadioButton radioButton = new RadioButton(context); radioButton.setLayoutParams(buttonLayoutParams); radioButton.setButtonDrawable(android.R.color.transparent); radioButton.setBackgroundResource(R.drawable.wizard_custom_indicator); radioButton.setClickable(false); radioGroup.addView(radioButton); wizardButtons.add(radioButton); } }
Example 3
Source File: ViewPagerIndicator.java From EtsyBlur with Apache License 2.0 | 6 votes |
public void setPageCount(int pageCount) { this.pageCount = pageCount; removeAllViews(); for (int i = 0; i < pageCount; i++) { RadioButton rb = new RadioButton(getContext()); rb.setFocusable(false); rb.setClickable(false); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { Drawable d = ContextCompat.getDrawable(getContext(), R.drawable.indicator); rb.setButtonDrawable(d); LinearLayout.LayoutParams params = generateDefaultLayoutParams(); params.width = d.getIntrinsicWidth(); params.height = d.getIntrinsicHeight(); rb.setLayoutParams(params); } else { rb.setButtonDrawable(R.drawable.indicator); } addView(rb); } setCurrentPosition(-1); }
Example 4
Source File: WidgetFragment.java From mobile-android-survey-app with MIT License | 5 votes |
protected RadioButton getRadioButton(Integer id, String text, String tag, String value) { RadioButton radioButton = new RadioButton(getActivity()); radioButton.setId(id); radioButton.setText(text); radioButton.setTag(tag); radioButton.setTextAppearance(getActivity(), R.style.RadioButton_Full); radioButton.setLayoutParams(getLayoutParams(labelDescription.getPaddingLeft(), labelDescription.getPaddingLeft() / 2, labelDescription.getPaddingRight(), labelDescription.getPaddingLeft() / 2)); if (value != null && value.equals(tag)) { radioButton.setChecked(true); } else { radioButton.setChecked(false); } return radioButton; }