This is a change Background Or TextColor Selector support library, with which you can directly specify the Background to be displayed in different states or TextColor Layout xml, such as clicking the button effect, the conventional practice is to create Selector xml file in drawable directory but when the project becomes larger when the file back to the directory Selector cause more and more difficult to maintain and achieve the Library can easily solve these problems, and can also achieve a lot Shape effects can be achieved, if you are using process have any questions or suggestions, please send an email to my email below, thank you!
For more information please see the website
<net.soulwolf.widget.speedyselector.widget.SelectorTextView
xmlns:soulwolf="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="8dp"
android:textSize="16sp"
android:clickable="true"
android:background="@color/sample_primary"
android:textColor="@color/sample_primary"
soulwolf:spStatePressedTextColor="@color/sample_accent"
soulwolf:spStatePressedBackground="@color/sample_accent"
soulwolf:spRadius="8dp"
soulwolf:spJustBorder="true"
soulwolf:spBorderWidth="1dp"
android:text="SelectorTextView"/>
<net.soulwolf.widget.speedyselector.widget.SelectorTextView
xmlns:soulwolf="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="8dp"
android:textSize="16sp"
android:layout_marginTop="8dp"
android:clickable="true"
android:background="@color/sample_primary"
android:textColor="@color/sample_primary"
soulwolf:spStatePressedTextColor="@color/sample_accent"
soulwolf:spStatePressedBackground="@color/sample_accent"
soulwolf:spRadius="0dp"
soulwolf:spJustBorder="true"
soulwolf:spBorderWidth="1dp"
android:text="SelectorTextView"/>
<net.soulwolf.widget.speedyselector.widget.SelectorTextView
xmlns:soulwolf="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="8dp"
android:textSize="16sp"
android:layout_marginTop="8dp"
android:clickable="true"
android:background="@color/sample_primary"
android:textColor="@color/sample_primary"
soulwolf:spStatePressedTextColor="@color/sample_accent"
soulwolf:spStatePressedBackground="@color/sample_accent"
soulwolf:spRadius="360dp"
soulwolf:spJustBorder="true"
soulwolf:spBorderWidth="1dp"
android:text="SelectorTextView"/>
<net.soulwolf.widget.speedyselector.widget.SelectorFrameLayout
xmlns:soulwolf="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_marginTop="8dp"
android:padding="20dp"
soulwolf:spStateDefaultBackground="@color/sample_primary"
soulwolf:spStatePressedBackground="@color/sample_accent"
soulwolf:spRadius="8dp"
android:clickable="true"
android:layout_height="wrap_content"/>
<net.soulwolf.widget.speedyselector.widget.SelectorFrameLayout
xmlns:soulwolf="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_marginTop="8dp"
android:padding="20dp"
soulwolf:spStateDefaultBackground="@color/sample_primary"
soulwolf:spStatePressedBackground="@color/sample_accent"
soulwolf:spRadius="0dp"
android:clickable="true"
android:layout_height="wrap_content"/>
<net.soulwolf.widget.speedyselector.widget.SelectorFrameLayout
android:layout_width="match_parent"
android:layout_marginTop="8dp"
android:padding="20dp"
soulwolf:spStateDefaultBackground="@color/sample_primary"
soulwolf:spStatePressedBackground="@color/sample_accent"
soulwolf:spRadius="360dp"
android:clickable="true"
android:layout_height="wrap_content"/>
<net.soulwolf.widget.speedyselector.widget.SelectorRelativeLayout
xmlns:soulwolf="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_marginTop="8dp"
android:padding="8dp"
soulwolf:spStateDefaultBackground="@color/sample_primary"
soulwolf:spStatePressedBackground="@color/sample_accent"
soulwolf:spRadius="8dp"
soulwolf:spJustBorder="true"
soulwolf:spBorderWidth="1dp"
android:clickable="true"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="SelectorRelativeLayout"
android:gravity="center"/>
</net.soulwolf.widget.speedyselector.widget.SelectorRelativeLayout>
<net.soulwolf.widget.speedyselector.widget.SelectorRelativeLayout
xmlns:soulwolf="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_marginTop="8dp"
android:padding="8dp"
soulwolf:spStateDefaultBackground="@color/sample_primary"
soulwolf:spStatePressedBackground="@color/sample_accent"
soulwolf:spRadius="0dp"
soulwolf:spJustBorder="true"
soulwolf:spBorderWidth="1dp"
android:clickable="true"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="SelectorRelativeLayout"
android:gravity="center"/>
</net.soulwolf.widget.speedyselector.widget.SelectorRelativeLayout>
<net.soulwolf.widget.speedyselector.widget.SelectorRelativeLayout
xmlns:soulwolf="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_marginTop="8dp"
android:padding="8dp"
soulwolf:spStateDefaultBackground="@color/sample_primary"
soulwolf:spStatePressedBackground="@color/sample_accent"
soulwolf:spRadius="360dp"
soulwolf:spJustBorder="true"
soulwolf:spBorderWidth="1dp"
android:clickable="true"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="SelectorRelativeLayout"
android:gravity="center"/>
</net.soulwolf.widget.speedyselector.widget.SelectorRelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:gravity="center_horizontal"
android:orientation="horizontal">
<net.soulwolf.widget.speedyselector.widget.SelectorLinearLayout
xmlns:soulwolf="http://schemas.android.com/apk/res-auto"
android:layout_width="150dp"
android:layout_height="150dp"
soulwolf:spStateDefaultBackground="@color/sample_primary"
soulwolf:spStatePressedBackground="@color/sample_accent"
soulwolf:spRadius="360dp"
android:clickable="true"
android:gravity="center"
android:padding="8dp"
soulwolf:spJustBorder="true"
soulwolf:spBorderWidth="1dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SelectorLinearLayout"/>
</net.soulwolf.widget.speedyselector.widget.SelectorLinearLayout>
<net.soulwolf.widget.speedyselector.widget.SelectorLinearLayout
xmlns:soulwolf="http://schemas.android.com/apk/res-auto"
android:layout_width="150dp"
android:layout_height="150dp"
soulwolf:spStateDefaultBackground="@color/sample_primary"
soulwolf:spStatePressedBackground="@color/sample_accent"
soulwolf:spRadius="360dp"
android:padding="8dp"
android:clickable="true"
android:layout_marginLeft="20dp"
android:gravity="center"
soulwolf:spJustBorder="false"
soulwolf:spBorderWidth="1dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SelectorLinearLayout"/>
</net.soulwolf.widget.speedyselector.widget.SelectorLinearLayout>
</LinearLayout>
// BackgroundSelector
public void addStateBackground(StateType state,Drawable drawable);
public void addStateBackgroundResource(StateType state,@DrawableRes int draRes);
public void addStateBackground(StateType state,float radius,@ColorInt int color);
public void addStateBackground(StateType state,float radius,boolean justBorder,@ColorInt int color);
public void addStateBackground(StateType state,float radius,boolean justBorder,float borderWidth,@ColorInt int color);
public void addStateBackgroundResource(StateType state,float radius,@ColorRes int colorRes);
public void addStateBackgroundResource(StateType state,float radius,boolean justBorder,@ColorRes int colorRes);
public void addStateBackgroundResource(StateType state,float radius,boolean justBorder,float borderWidth,@ColorRes int colorRes);
public void requestSelector();
// TextColorSelector
public void setTextColorResource(@ColorRes int resId);
public void addTextStateColor(StateType state,@ColorInt int color);
public void addTextStateColorResource(StateType state, @ColorRes int colorRes);
public void requestSelector();
attrName | Explanation |
spRadius | This parameter is used to set the radius of each corner Background! |
spJustBorder | This parameter indicates whether to draw only border |
spBorderWidth | This parameter indicates the width of the border |
spStateDefaultBackground spStateDefaultTextColor |
Background Or TextColor this parameter default to be displayed |
spStateFocusedBackground spStateFocusedTextColor |
Background Or TextColor this parameter StateFocused to be displayed |
spStateWindowFocusedBackground spStateWindowFocusedTextColor |
Background Or TextColor this parameter StateWindowFocused to be displayed |
spStateEnabledBackground spStateEnabledTextColor |
Background Or TextColor this parameter StateEnabled to be displayed |
spStateCheckedBackground spStateCheckedTextColor |
Background Or TextColor this parameter StateChecked to be displayed |
spStateSelectedBackground spStateSelectedTextColor |
Background Or TextColor this parameter StateSelected to be displayed |
spStateActivatedBackground spStateActivatedTextColor |
Background Or TextColor this parameter StateActivated to be displayed |
spStatePressedBackground spStatePressedTextColor |
Background Or TextColor this parameter StatePressed to be displayed |
spStateActiveBackground spStateActiveTextColor |
Background Or TextColor this parameter StateActive to be displayed |
- SelectorAbsoluteLayout
- SelectorButton
- SelectorCheckBox
- SelectorEditText
- SelectorFrameLayout
- SelectorGridLayout