Java Code Examples for android.support.v7.widget.SwitchCompat#setPadding()
The following examples show how to use
android.support.v7.widget.SwitchCompat#setPadding() .
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: TvShowEpisodesFragment.java From Mizuu with Apache License 2.0 | 6 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.episodes_overview, menu); int padding = MizLib.convertDpToPixels(getActivity(), 16); SwitchCompat switchCompat = (SwitchCompat) menu.findItem(R.id.switch_button).getActionView(); switchCompat.setChecked(mEpisodeLoader != null ? mEpisodeLoader.showAvailableFiles() : false); switchCompat.setText(R.string.choiceAvailableFiles); switchCompat.setSwitchPadding(padding); switchCompat.setPadding(0, 0, padding, 0); switchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mEpisodeLoader.setShowAvailableFiles(isChecked); mEpisodeLoader.load(); showProgressBar(); } }); super.onCreateOptionsMenu(menu, inflater); }
Example 2
Source File: ActorMoviesFragment.java From Mizuu with Apache License 2.0 | 6 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.switch_button, menu); int padding = MizLib.convertDpToPixels(getActivity(), 16); SwitchCompat switchCompat = (SwitchCompat) menu.findItem(R.id.switch_button).getActionView(); switchCompat.setChecked(mChecked); switchCompat.setText(R.string.inLibrary); switchCompat.setSwitchPadding(padding); switchCompat.setPadding(0, 0, padding, 0); switchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mChecked = isChecked; mAdapter.notifyDataSetChanged(); } }); super.onCreateOptionsMenu(menu, inflater); }
Example 3
Source File: ActorTvShowsFragment.java From Mizuu with Apache License 2.0 | 6 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.switch_button, menu); int padding = MizLib.convertDpToPixels(getActivity(), 16); SwitchCompat switchCompat = (SwitchCompat) menu.findItem(R.id.switch_button).getActionView(); switchCompat.setChecked(mChecked); switchCompat.setText(R.string.inLibrary); switchCompat.setSwitchPadding(padding); switchCompat.setPadding(0, 0, padding, 0); switchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mChecked = isChecked; mAdapter.notifyDataSetChanged(); } }); super.onCreateOptionsMenu(menu, inflater); }
Example 4
Source File: SwitchPreference.java From narrate-android with Apache License 2.0 | 4 votes |
@Override public void init() { super.init(); mSwitch = new SwitchCompat(getContext()) { boolean isTouched = false; @Override public void setChecked(boolean checked) { if ( isTouched || mForced ) { super.setChecked(checked); if ( isTouched && mListener != null ) { isTouched = false; mListener.onCheckedChanged(this, checked); } mForced = false; } } @Override public boolean onTouchEvent(MotionEvent ev) { isTouched = true; return super.onTouchEvent(ev); } }; mSwitch.setId(R.id.settings_switch); RelativeLayout.LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); mSwitch.setLayoutParams(lp); lp = (LayoutParams) mTextView.getLayoutParams(); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.addRule(RelativeLayout.LEFT_OF, mSwitch.getId()); mTextView.setLayoutParams(lp); int p = getResources().getDimensionPixelOffset(R.dimen.eight_dp) / 4; mSwitch.setPadding(p, p, p, p); addView(mSwitch); }