本文整理了Java中android.widget.CheckBox.setGravity()
方法的一些代码示例,展示了CheckBox.setGravity()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CheckBox.setGravity()
方法的具体详情如下:
包路径:android.widget.CheckBox
类名称:CheckBox
方法名:setGravity
暂无
代码示例来源: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: 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;
}
内容来源于网络,如有侵权,请联系作者删除!