@@ -169,6 +169,8 @@ public Switch(Context context, AttributeSet attrs, int defStyle) {
169169 /**
170170 * Sets the switch text color, size, style, hint color, and highlight color
171171 * from the specified TextAppearance resource.
172+ *
173+ * @attr ref android.R.styleable#Switch_switchTextAppearance
172174 */
173175 public void setSwitchTextAppearance (Context context , int resid ) {
174176 TypedArray appearance =
@@ -273,15 +275,138 @@ public void setSwitchTypeface(Typeface tf) {
273275 }
274276 }
275277
278+ /**
279+ * Set the amount of horizontal padding between the switch and the associated text.
280+ *
281+ * @param pixels Amount of padding in pixels
282+ *
283+ * @attr ref android.R.styleable#Switch_switchPadding
284+ */
285+ public void setSwitchPadding (int pixels ) {
286+ mSwitchPadding = pixels ;
287+ requestLayout ();
288+ }
289+
290+ /**
291+ * Get the amount of horizontal padding between the switch and the associated text.
292+ *
293+ * @return Amount of padding in pixels
294+ *
295+ * @attr ref android.R.styleable#Switch_switchPadding
296+ */
297+ public int getSwitchPadding () {
298+ return mSwitchPadding ;
299+ }
300+
301+ /**
302+ * Set the minimum width of the switch in pixels. The switch's width will be the maximum
303+ * of this value and its measured width as determined by the switch drawables and text used.
304+ *
305+ * @param pixels Minimum width of the switch in pixels
306+ *
307+ * @attr ref android.R.styleable#Switch_switchMinWidth
308+ */
309+ public void setSwitchMinWidth (int pixels ) {
310+ mSwitchMinWidth = pixels ;
311+ requestLayout ();
312+ }
313+
314+ /**
315+ * Get the minimum width of the switch in pixels. The switch's width will be the maximum
316+ * of this value and its measured width as determined by the switch drawables and text used.
317+ *
318+ * @return Minimum width of the switch in pixels
319+ *
320+ * @attr ref android.R.styleable#Switch_switchMinWidth
321+ */
322+ public int getSwitchMinWidth () {
323+ return mSwitchMinWidth ;
324+ }
325+
326+ /**
327+ * Set the horizontal padding around the text drawn on the switch itself.
328+ *
329+ * @param pixels Horizontal padding for switch thumb text in pixels
330+ *
331+ * @attr ref android.R.styleable#Switch_thumbTextPadding
332+ */
333+ public void setThumbTextPadding (int pixels ) {
334+ mThumbTextPadding = pixels ;
335+ requestLayout ();
336+ }
337+
338+ /**
339+ * Get the horizontal padding around the text drawn on the switch itself.
340+ *
341+ * @return Horizontal padding for switch thumb text in pixels
342+ *
343+ * @attr ref android.R.styleable#Switch_thumbTextPadding
344+ */
345+ public int getThumbTextPadding () {
346+ return mThumbTextPadding ;
347+ }
348+
349+ /**
350+ * Set the drawable used for the track that the switch slides within.
351+ *
352+ * @param track Track drawable
353+ *
354+ * @attr ref android.R.styleable#Switch_track
355+ */
356+ public void setTrackDrawable (Drawable track ) {
357+ mTrackDrawable = track ;
358+ requestLayout ();
359+ }
360+
361+ /**
362+ * Get the drawable used for the track that the switch slides within.
363+ *
364+ * @return Track drawable
365+ *
366+ * @attr ref android.R.styleable#Switch_track
367+ */
368+ public Drawable getTrackDrawable () {
369+ return mTrackDrawable ;
370+ }
371+
372+ /**
373+ * Set the drawable used for the switch "thumb" - the piece that the user
374+ * can physically touch and drag along the track.
375+ *
376+ * @param thumb Thumb drawable
377+ *
378+ * @attr ref android.R.styleable#Switch_thumb
379+ */
380+ public void setThumbDrawable (Drawable thumb ) {
381+ mThumbDrawable = thumb ;
382+ requestLayout ();
383+ }
384+
385+ /**
386+ * Get the drawable used for the switch "thumb" - the piece that the user
387+ * can physically touch and drag along the track.
388+ *
389+ * @return Thumb drawable
390+ *
391+ * @attr ref android.R.styleable#Switch_thumb
392+ */
393+ public Drawable getThumbDrawable () {
394+ return mThumbDrawable ;
395+ }
396+
276397 /**
277398 * Returns the text displayed when the button is in the checked state.
399+ *
400+ * @attr ref android.R.styleable#Switch_textOn
278401 */
279402 public CharSequence getTextOn () {
280403 return mTextOn ;
281404 }
282405
283406 /**
284407 * Sets the text displayed when the button is in the checked state.
408+ *
409+ * @attr ref android.R.styleable#Switch_textOn
285410 */
286411 public void setTextOn (CharSequence textOn ) {
287412 mTextOn = textOn ;
@@ -290,13 +415,17 @@ public void setTextOn(CharSequence textOn) {
290415
291416 /**
292417 * Returns the text displayed when the button is not in the checked state.
418+ *
419+ * @attr ref android.R.styleable#Switch_textOff
293420 */
294421 public CharSequence getTextOff () {
295422 return mTextOff ;
296423 }
297424
298425 /**
299426 * Sets the text displayed when the button is not in the checked state.
427+ *
428+ * @attr ref android.R.styleable#Switch_textOff
300429 */
301430 public void setTextOff (CharSequence textOff ) {
302431 mTextOff = textOff ;
0 commit comments