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

x33g5p2x  于2022-01-29 转载在 其他  
字(2.4k)|赞(0)|评价(0)|浏览(120)

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

Switch.setLayoutParams介绍

暂无

代码示例

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

mSwitchParams.setMargins(0, 0, rightSwitchMarginRight, 0);
mSwitch.setId(R.id.sRightSwitchId);
mSwitch.setLayoutParams(mSwitchParams);

代码示例来源:origin: mooshim/Mooshimeter-AndroidApp

Switch makeSwitch(boolean checked, final BooleanRunnable cb) {
  Switch s = new Switch(mContext);
  s.setChecked(checked);
  s.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
      cb.arg = isChecked;
      cb.run();
    }
  });
  s.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,FrameLayout.LayoutParams.MATCH_PARENT));
  return s;
}
public Switch makeSwitchForPreference(final String pref_name) {

代码示例来源:origin: renyuneyun/Easer

@NonNull
@Override
public ViewGroup onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  LinearLayout view = new LinearLayout(getContext());
  view.setOrientation(LinearLayout.VERTICAL);
  LinearLayout auto_layout = new LinearLayout(getContext());
  auto_layout.setOrientation(LinearLayout.HORIZONTAL);
  TextView tv_auto = new TextView(getContext());
  tv_auto.setText(getResources().getString(R.string.operation_brightness_desc_autobrightness));
  mIsAuto = new Switch(getContext());
  mIsAuto.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
  mBrightnessLevel = new SeekBar(getContext());
  mBrightnessLevel.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
  mBrightnessLevel.setMax(255);
  mBrightnessLevel.setEnabled(false);
  mIsAuto.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
      if (isChecked)
        mBrightnessLevel.setEnabled(false);
      else
        mBrightnessLevel.setEnabled(true);
    }
  });
  auto_layout.addView(mIsAuto);
  auto_layout.addView(tv_auto);
  view.addView(auto_layout);
  view.addView(mBrightnessLevel);
  return view;
}

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

case Switch:
  mSwitch = new Switch(mContext);
  mSwitch.setLayoutParams(params);
  mSwitch.setOnCheckedChangeListener(this);
  setValue(getValue());

相关文章