step1 在project目錄的build.gradle的allprojects節(jié)點添加
maven { url "https://jitpack.io" }
step2 在自己Modul的build.gradle中添加
dependencies {
compile 'com.github.yanjiabin:SwitchView:-SNAPSHOT'
}
開始使用
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#fff"
android:paddingLeft="15dp"
android:paddingRight="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerInParent="true"
android:gravity="center"
android:text="名稱"
android:textColor="#000"
android:textSize="16sp" />
<com.github.yanjiabin.switchview.SwitchView
android:id="@+id/name"
android:layout_width="60dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_centerInParent="true" />
</RelativeLayout>
...
<declare-styleable name="SwitchView">
<attr name="hasShadow" format="boolean" /> 這個屬性是表示是否要陰影效果
<attr name="primaryColor" format="color" /> 這個屬性是表示背景的顏色
<attr name="primaryColorDark" format="color" />
<attr name="isOpened" format="boolean" /> 默認是開還是關(guān)true表示的開false表示的關(guān)
</declare-styleable>
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者