• Stars
    star
    170
  • Rank 223,357 (Top 5 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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!

Android-SpeedyViewSelector

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

Screenshots

Sample1

Android-SpeedyViewSelector with xml code

	   <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>

Android-SpeedyViewSelector with java code

	// 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();

Attr params info

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

Implementing View!

  • SelectorAbsoluteLayout
  • SelectorButton
  • SelectorCheckBox
  • SelectorEditText
  • SelectorFrameLayout
  • SelectorGridLayout
  • SelectorImageButton
  • SelectorLinearLayout
  • SelectorRadioButton
  • SelectorRadioGroup
  • SelectorRelativeLayout
  • SelectorTableLayout
  • SelectorTextView
  • SelectorView

Custom

	// Background Selector
	public class SelectorFrameLayout extends FrameLayout implements BackgroundSelector{

	    SpeedySelectorDelegate mSpeedySelectorDelegate;
	
	    public SelectorFrameLayout(Context context) {
	        super(context);
	        mSpeedySelectorDelegate = SpeedySelectorDelegate.obtain(this);
	    }
	
	    public SelectorFrameLayout(Context context, AttributeSet attrs) {
	        super(context, attrs);
	        mSpeedySelectorDelegate = SpeedySelectorDelegate.obtain(this,attrs);
	    }
	
	    public SelectorFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
	        super(context, attrs, defStyleAttr);
	        mSpeedySelectorDelegate = SpeedySelectorDelegate.obtain(this,attrs,defStyleAttr);
	    }
	
	    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
	    public SelectorFrameLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
	        super(context, attrs, defStyleAttr, defStyleRes);
	        mSpeedySelectorDelegate = SpeedySelectorDelegate.obtain(this,attrs,defStyleAttr,defStyleRes);
	    }
	
	    @Override
	    public void addStateBackground(StateType state, Drawable drawable) {
	        mSpeedySelectorDelegate.addStateBackground(state,drawable);
	    }
	
	    @Override
	    public void addStateBackgroundResource(StateType state, @DrawableRes int draRes) {
	        mSpeedySelectorDelegate.addStateBackgroundResource(state, draRes);
	    }
	
	    @Override
	    public void addStateBackground(StateType state, float radius, @ColorInt int color) {
	        mSpeedySelectorDelegate.addStateBackground(state,radius,color);
	    }
	
	    @Override
	    public void addStateBackground(StateType state, float radius, boolean justBorder, @ColorInt int color) {
	        mSpeedySelectorDelegate.addStateBackground(state,radius,justBorder,color);
	    }
	
	    @Override
	    public void addStateBackground(StateType state, float radius, boolean justBorder, float borderWidth, @ColorInt int color) {
	        mSpeedySelectorDelegate.addStateBackground(state,radius,justBorder,borderWidth,color);
	    }
	
	    @Override
	    public void addStateBackgroundResource(StateType state, float radius, @ColorRes int colorRes) {
	        mSpeedySelectorDelegate.addStateBackgroundResource(state, radius,colorRes);
	    }
	
	    @Override
	    public void addStateBackgroundResource(StateType state, float radius, boolean justBorder, @ColorRes int colorRes) {
	        mSpeedySelectorDelegate.addStateBackgroundResource(state, radius,justBorder,colorRes);
	    }
	
	    @Override
	    public void addStateBackgroundResource(StateType state, float radius, boolean justBorder, float borderWidth, @ColorRes int colorRes) {
	        mSpeedySelectorDelegate.addStateBackgroundResource(state, radius,justBorder,borderWidth,colorRes);
	    }
	
	    @Override
	    public void requestSelector() {
	        mSpeedySelectorDelegate.requestSelector();
	    }
	}

	// General Selector
	public class SelectorTextView extends TextView implements GeneralSelector{

	    SpeedySelectorDelegate mSpeedySelectorDelegate;
	
	    public SelectorTextView(Context context) {
	        super(context);
	        mSpeedySelectorDelegate = SpeedySelectorDelegate.obtainGeneral(this);
	    }
	
	    public SelectorTextView(Context context, AttributeSet attrs) {
	        super(context, attrs);
	        mSpeedySelectorDelegate = SpeedySelectorDelegate.obtainGeneral(this, attrs);
	    }
	
	    public SelectorTextView(Context context, AttributeSet attrs, int defStyleAttr) {
	        super(context, attrs, defStyleAttr);
	        mSpeedySelectorDelegate = SpeedySelectorDelegate.obtainGeneral(this, attrs, defStyleAttr);
	    }
	
	    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
	    public SelectorTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
	        super(context, attrs, defStyleAttr, defStyleRes);
	        mSpeedySelectorDelegate = SpeedySelectorDelegate.obtainGeneral(this, attrs, defStyleAttr, defStyleRes);
	    }
	
	    @Override
	    public void addStateBackground(StateType state, Drawable drawable) {
	        mSpeedySelectorDelegate.addStateBackground(state,drawable);
	    }
	
	    @Override
	    public void addStateBackgroundResource(StateType state, @DrawableRes int draRes) {
	        mSpeedySelectorDelegate.addStateBackgroundResource(state, draRes);
	    }
	
	    @Override
	    public void addStateBackground(StateType state, float radius, @ColorInt int color) {
	        mSpeedySelectorDelegate.addStateBackground(state,radius,color);
	    }
	
	    @Override
	    public void addStateBackground(StateType state, float radius, boolean justBorder, @ColorInt int color) {
	        mSpeedySelectorDelegate.addStateBackground(state,radius,justBorder,color);
	    }
	
	    @Override
	    public void addStateBackground(StateType state, float radius, boolean justBorder, float borderWidth, @ColorInt int color) {
	        mSpeedySelectorDelegate.addStateBackground(state,radius,justBorder,borderWidth,color);
	    }
	
	    @Override
	    public void addStateBackgroundResource(StateType state, float radius, @ColorRes int colorRes) {
	        mSpeedySelectorDelegate.addStateBackgroundResource(state, radius,colorRes);
	    }
	
	    @Override
	    public void addStateBackgroundResource(StateType state, float radius, boolean justBorder, @ColorRes int colorRes) {
	        mSpeedySelectorDelegate.addStateBackgroundResource(state, radius,justBorder,colorRes);
	    }
	
	    @Override
	    public void addStateBackgroundResource(StateType state, float radius, boolean justBorder, float borderWidth, @ColorRes int colorRes) {
	        mSpeedySelectorDelegate.addStateBackgroundResource(state, radius,justBorder,borderWidth,colorRes);
	    }
	
	    @Override
	    public void setTextColorResource(@ColorRes int resId) {
	        mSpeedySelectorDelegate.setTextColorRessource(resId);
	    }
	
	    @Override
	    public void addTextStateColor(StateType state, @ColorInt int color) {
	        mSpeedySelectorDelegate.addTextStateColor(state,color);
	    }
	
	    @Override
	    public void addTextStateColorResource(StateType state, @ColorRes int colorRes) {
	        mSpeedySelectorDelegate.addTextStateColorRessource(state, colorRes);
	    }
	
	    @Override
	    public void requestSelector() {
	        mSpeedySelectorDelegate.requestSelector();
	    }
	}

Maven

<dependency>
    <groupId>net.soulwolf.widget</groupId>
	<url>https://dl.bintray.com/soulwolf/maven</url>
    <artifactId>speedySelector</artifactId>
    <version>1.0.0</version>
</dependency>

Gradle

allprojects {
   repositories {
      jcenter()
   }
}

compile 'net.soulwolf.widget:speedySelector:1.0.0'

Developed by

Ching Soulwolf - [email protected]

License

Copyright 2015 Soulwolf Ching
Copyright 2015 The Android Open Source Project for Android-SpeedyViewSelector

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

Android-RatioLayout

This is a specified proportion to the size of the Layout or View support library, with which you can easily set a fixed ratio of the size of the Layout or View, internal adaptive size calculation, completely abandon the code to calculate the size! If you have any questions in the course or suggestions, please send an e-mail to the following e-mail, thank you!
Java
459
star
2

MaterialRadioGroup

This is a cool radio button group!
Java
106
star
3

PictureChooseLib

This is a picture select Android library that supports camera to take pictures, picture gallery multiple choice, image shearing!
Java
102
star
4

android-dialog-builder

android-dialog-builder
Java
63
star
5

RoundedLayout

This is a library that has a rounded cut of View, support whether the specified corners are cropped and add a custom Border, and add a shadow support from API 9, which is based on FrameLayout, that is, His Child can be any View, the current library or preview version, if you encounter problems in the process can submit issue or pr.
Java
24
star
6

WebViewJavascriptBridge

This is a communication between Android applications and Web Javascript to establish a bridge between the call support each other
Java
17
star
7

Android-ParallaxRefresh

This is a drop-down head View supports parallax effect, support refresh libraries!
Java
13
star
8

TLog-master

Used in the project development Debug log print management!
Java
4
star
9

KatanaListView

This is a realization of the ListView and GridView LAC library contained more features, support for custom add animation。
Java
3
star
10

Observable

This is a thread scheduling library, time-consuming operation in the child thread, the main thread to update the UI
Java
3
star
11

framework-master

framework-master by android
Java
2
star
12

AppStructure

AppStructure
Java
1
star
13

volley-master

google volley NetWork tools
Java
1
star
14

Honor_7x_recovery-flasher

script tool for flashing stock and twrp recovery on Nougat and Oreo
Batchfile
1
star
15

LayeredCover-master

LayeredCover-master
Java
1
star
16

DesignBeyondLayout

This is a header ViewPager!
Java
1
star