目录

HwSwitch

Class Info

public class HwSwitch extends android.widget.Switch

该类扩展了华为EMUI主题的样式。

XML Attributes

Qualifier and Type

Attributes Name and Description

dimension

hwLayoutPadding

小白球到边界的距离。

Style Summary

Style Name

Style Description

Widget.Emui.HwSwitch

HwSwitch默认风格。

Widget.Emui.HwSwitch.Light

HwSwitch浅色风格。

Public Constructor Summary

Constructor Name

public HwSwitch(Context context)

通过代码实例化HwSwitch对象。

public HwSwitch(Context context, AttributeSet attrs)

通过XML实例化HwSwitch对象。

public HwSwitch(Context context, AttributeSet attrs, int defStyleAttr)

通过XML实例化HwSwitch对象,并应用主题中定义的样式。

Public Method Summary

Qualifier and Type

Method Name and Description

static HwSwitch

instantiate(Context context)

实例化HwSwitch对象。

Methods Inherited from Class android.widget.switch

onLayout, onDraw, setChecked, onTouchEvent

Public Constructors

[h2]HwSwitch(Context context)

Constructor

public HwSwitch(Context context)

通过代码实例化HwSwitch对象。

Parameters

Name

Description

context

控件的上下文。

[h2]HwSwitch(Context context, AttributeSet attrs)

Constructor

public HwSwitch(Context context, AttributeSet attrs)

通过XML实例化HwSwitch对象。

Parameters

Name

Description

context

控件的上下文。

attrs

XML中配置的控件属性集合。

[h2]HwSwitch(Context context, AttributeSet attrs, int defStyleAttr)

Constructor

public HwSwitch(Context context, AttributeSet attrs, int defStyleAttr)

通过XML实例化HwSwitch对象,并应用主题中定义的样式。

Parameters

Name

Description

context

控件的上下文。

attrs

XML中配置的控件属性集合。

defStyleAttr

当前主题中配置的控件默认样式,为0表示不应用默认样式。

Public Methods

[h2]instantiate

Method

public static HwSwitch instantiate(Context context)

实例化HwSwitch对象。

Parameters

Name

Description

context

控件的上下文。

Returns

Type

Description

HwSwitch

实例化多态对象,若未适配多态,可能返回为空。