本文整理了Java中android.widget.Switch.setPadding()
方法的一些代码示例,展示了Switch.setPadding()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Switch.setPadding()
方法的具体详情如下:
包路径:android.widget.Switch
类名称:Switch
方法名:setPadding
暂无
代码示例来源:origin: nvanbenschoten/motion
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.parallax, menu);
// Add parallax toggle
final Switch mParallaxToggle = new Switch(getActivity());
mParallaxToggle.setPadding(0, 0, (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, getResources().getDisplayMetrics()), 0);
mParallaxToggle.setChecked(mParallaxSet);
mParallaxToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
mBackground.registerSensorManager();
} else {
mBackground.unregisterSensorManager();
}
mParallaxSet = isChecked;
}
});
MenuItem switchItem = menu.findItem(R.id.action_parallax);
if (switchItem != null)
switchItem.setActionView(mParallaxToggle);
// Set lock/ unlock orientation text
if (mPortraitLock) {
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
MenuItem orientationItem = menu.findItem(R.id.action_portrait);
if (orientationItem != null)
orientationItem.setTitle(R.string.action_unlock_portrait);
}
}
代码示例来源:origin: marzika/Snapprefs
private void applyLogTypeSwitches(LinearLayout layout) {
LogType[] logTypes = Logger.LogType.values();
final float scale = getContext().getResources().getDisplayMetrics().density;
HashSet<String> activeTypes = Logger.getActiveLogTypes();
for (LogType logType : logTypes) {
Switch logSwitch = new Switch(layout.getContext());
int pad = (int) (10f * scale);
logSwitch.setPadding(pad, pad / 2, pad, pad / 2);
logSwitch.setText(logType.name());
logSwitch.setChecked(activeTypes.contains(logType.name()));
logSwitch.setTextSize(7f * scale);
logSwitch.setTextColor(Color.GRAY);
logSwitch.setTag(logType.name());
logSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean state) {
String tag = (String) compoundButton.getTag();
Logger.setLogTypeState(tag, state);
}
});
layout.addView(logSwitch);
}
}
}
代码示例来源:origin: linglongxin24/ARDevelopDemo
newSwitchView.setTag(command);
newSwitchView.setVisibility(View.VISIBLE);
newSwitchView.setPadding(mEntriesSidesPadding,
mEntriesUpDownPadding, mEntriesSidesPadding,
mEntriesUpDownPadding);
内容来源于网络,如有侵权,请联系作者删除!