android.widget.CheckBox.setLayoutParams()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(142)

本文整理了Java中android.widget.CheckBox.setLayoutParams()方法的一些代码示例,展示了CheckBox.setLayoutParams()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CheckBox.setLayoutParams()方法的具体详情如下:
包路径:android.widget.CheckBox
类名称:CheckBox
方法名:setLayoutParams

CheckBox.setLayoutParams介绍

暂无

代码示例

代码示例来源:origin: gzu-liyujiang/AndroidPicker

@NonNull
@Override
protected ScrollView makeCenterView() {
  ScrollView scrollView = new ScrollView(activity);
  layout = new LinearLayout(activity);
  layout.setOrientation(LinearLayout.VERTICAL);
  for (String item : items) {
    LinearLayout line = new LinearLayout(activity);
    line.setOrientation(LinearLayout.HORIZONTAL);
    line.setGravity(Gravity.CENTER);
    TextView textView = new TextView(activity);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, WRAP_CONTENT, 1.0f);
    lp.gravity = Gravity.CENTER;
    textView.setLayoutParams(lp);
    textView.setText(item);
    textView.setGravity(Gravity.CENTER);
    line.addView(textView);
    CheckBox checkBox = new CheckBox(activity);
    checkBox.setLayoutParams(new LinearLayout.LayoutParams(0, WRAP_CONTENT, 0.4f));
    line.addView(checkBox);
    layout.addView(line);
  }
  scrollView.addView(layout);
  return scrollView;
}

代码示例来源:origin: lygttpod/SuperTextView

/**
 * 初始化RightCheckBox
 */
private void initRightCheckBox() {
  if (rightCheckBox == null) {
    rightCheckBox = new CheckBox(mContext);
  }
  rightCheckBoxParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
  rightCheckBoxParams.addRule(ALIGN_PARENT_RIGHT, TRUE);
  rightCheckBoxParams.addRule(RelativeLayout.CENTER_VERTICAL, TRUE);
  rightCheckBoxParams.setMargins(0, 0, rightCheckBoxMarginRight, 0);
  rightCheckBox.setId(R.id.sRightCheckBoxId);
  rightCheckBox.setLayoutParams(rightCheckBoxParams);
  if (rightCheckBoxBg != null) {
    rightCheckBox.setGravity(CENTER_IN_PARENT);
    rightCheckBox.setButtonDrawable(rightCheckBoxBg);
  }
  rightCheckBox.setChecked(isChecked);
  rightCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
      if (checkBoxCheckedChangeListener != null) {
        checkBoxCheckedChangeListener.onCheckedChanged(buttonView, isChecked);
      }
    }
  });
  addView(rightCheckBox);
}

代码示例来源:origin: stackoverflow.com

public BooleanAdapter(Context context)
{   
  AbsListView.LayoutParams lp = new AbsListView.LayoutParams(AbsListView.LayoutParams.WRAP_CONTENT, AbsListView.LayoutParams.WRAP_CONTENT);
  TextView txt = new TextView(context);
  txt.setText("Clear filter");
  txt.setLayoutParams(lp);
  values.add(txt);

  CheckBox cb1 = new CheckBox(context);
  cb1.setClickable(false);
  cb1.setChecked(true);
  cb1.setLayoutParams(lp);
  values.add(cb1);

  CheckBox cb2 = new CheckBox(context);
  cb2.setClickable(false);
  cb2.setChecked(false);
  cb2.setLayoutParams(lp);
  values.add(cb2);
}

代码示例来源:origin: lltvcn/FreeText

private void addView(String str) {
  CheckBox tv = new CheckBox(viewContainer.getContext());
  tv.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
  tv.setText(str);
  viewContainer.addView(tv);
  if(obj!=null&&obj.equals(getString(str))){
    tv.setChecked(true);
  }
  tv.setOnCheckedChangeListener(lis);
}

代码示例来源:origin: Chion82/WeChatMomentStat-Android

protected void loadUserList() {
  LinearLayout userListContainer = (LinearLayout)findViewById(R.id.user_list_container);
  ArrayList<UserSnsInfo> userSnsList = Share.snsData.userSnsList;
  checkBoxList.clear();
  userListContainer.removeAllViews();
  for (int i=0;i<userSnsList.size();i++) {
    CheckBox userCheckBox = new CheckBox(this);
    userCheckBox.setText(userSnsList.get(i).userName + "(" + userSnsList.get(i).userId + ")" + "(" + String.format(getString(R.string.user_moment_count), userSnsList.get(i).snsList.size()) + ")");
    userListContainer.addView(userCheckBox);
    LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)userCheckBox.getLayoutParams();
    layoutParams.setMargins(5, 5, 5, 5);
    userCheckBox.setLayoutParams(layoutParams);
    userCheckBox.setChecked(true);
    userCheckBox.setTag(userSnsList.get(i).userId);
    checkBoxList.add(userCheckBox);
  }
}

代码示例来源:origin: thealeksandr/PFLockScreen-Android

private void setUpCodeViews() {
  removeAllViews();
  mCodeViews.clear();
  mCode = "";
  for (int i = 0; i < mCodeLength; i++) {
    LayoutInflater inflater = (LayoutInflater) getContext()
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    CheckBox view = (CheckBox) inflater.inflate(R.layout.view_pf_code_checkbox, null);
    LinearLayout.LayoutParams layoutParams = new LayoutParams(
        ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    int margin = getResources().getDimensionPixelSize(R.dimen.code_fp_margin);
    layoutParams.setMargins(margin, margin, margin, margin);
    view.setLayoutParams(layoutParams);
    view.setChecked(false);
    addView(view);
    mCodeViews.add(view);
  }
  if (mListener != null) {
    mListener.onCodeNotCompleted("");
  }
}

代码示例来源:origin: stackoverflow.com

check.setLayoutParams(innerParams1);

代码示例来源:origin: HelloChenJinJun/TestChat

public BaseDialog setCheckBoxName(List<String> list) {
    if (middleLayout.getChildCount() > 0) {
        middleLayout.removeAllViews();
    }
    for (String title :
        list) {
        TextView textView = new TextView(getContext());
        textView.setGravity(Gravity.START);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layoutParams.weight = 1;
        textView.setLayoutParams(layoutParams);
        textView.setText(title);
        final CheckBox checkBox = new CheckBox(getContext());
        checkBox.setGravity(Gravity.END);
        LinearLayout.LayoutParams checkBoxLayout = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        checkBoxLayout.weight = 1;
        checkBox.setLayoutParams(checkBoxLayout);
        LinearLayout linearLayout = new LinearLayout(getContext());
        LinearLayout.LayoutParams linearLayoutParam = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        linearLayout.setGravity(Gravity.CENTER_VERTICAL);
        linearLayout.setWeightSum(2);
        linearLayout.setLayoutParams(linearLayoutParam);
        linearLayout.addView(textView);
        linearLayout.addView(checkBox);
        middleLayout.addView(linearLayout);
    }
    return this;
}

代码示例来源:origin: HelloChenJinJun/TestChat

public BaseDialog setCheckBoxName(List<String> list) {
    if (middleLayout.getChildCount() > 0) {
        middleLayout.removeAllViews();
    }
    for (String title :
        list) {
        TextView textView = new TextView(getContext());
        textView.setGravity(Gravity.START);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layoutParams.weight = 1;
        textView.setLayoutParams(layoutParams);
        textView.setText(title);
        final CheckBox checkBox = new CheckBox(getContext());
        checkBox.setGravity(Gravity.END);
        LinearLayout.LayoutParams checkBoxLayout = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        checkBoxLayout.weight = 1;
        checkBox.setLayoutParams(checkBoxLayout);
        LinearLayout linearLayout = new LinearLayout(getContext());
        LinearLayout.LayoutParams linearLayoutParam = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        linearLayout.setGravity(Gravity.CENTER_VERTICAL);
        linearLayout.setWeightSum(2);
        linearLayout.setLayoutParams(linearLayoutParam);
        linearLayout.addView(textView);
        linearLayout.addView(checkBox);
        middleLayout.addView(linearLayout);
    }
    return this;
}

代码示例来源:origin: stackoverflow.com

layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
layoutParams.rightMargin = 30;
checkBox.setLayoutParams(layoutParams);
checkBox.setClickable(false);
if (selectedList != null) {

代码示例来源:origin: TobiasBielefeld/Simple-Solitaire

checkBox.setLayoutParams(layoutParams);
int index = gameOrder.indexOf(i);
checkBox.setChecked(results.get(index) == 1);

代码示例来源:origin: termux/termux-api

@Override
LinearLayout createWidgetView(AppCompatActivity activity) {
  LinearLayout layout = new LinearLayout(activity);
  layout.setOrientation(LinearLayout.VERTICAL);
  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];
    CheckBox checkBox = new CheckBox(activity);
    checkBox.setText(value);
    checkBox.setId(j);
    checkBox.setTextSize(18);
    checkBox.setPadding(16, 16, 16, 16);
    checkBox.setLayoutParams(layoutParams);
    layout.addView(checkBox);
  }
  return layout;
}

代码示例来源:origin: labexp/osmtracker-android

LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layoutParams.setMargins(60, 0, 0, 0);
newCheckBox.setLayoutParams(layoutParams);
newCheckBox.setPadding(10,20,10,20);
newCheckBox.setOnClickListener(listener);

代码示例来源:origin: supertaohaili/book

layoutParams.rightMargin = AndroidUtilities.dp(16);
layoutParams.gravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL;
checkBox.setLayoutParams(layoutParams);

代码示例来源:origin: Odoo-mobile/framework

mCheckbox.setLayoutParams(params);
mCheckbox.setOnCheckedChangeListener(this);
if (mLabel != null)

相关文章