GithubHelp home page GithubHelp logo

kaleai / selectorinjection Goto Github PK

View Code? Open in Web Editor NEW
638.0 638.0 76.0 2.68 MB

一个强大的selector注入器,它可以让view自动产生selector状态,免去了写selector文件的麻烦。

License: Apache License 2.0

Java 100.00%

selectorinjection's People

Contributors

jakewoki avatar kaleai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

selectorinjection's Issues

No resource identifier found for attribute

作者你好:
直接依赖compile 'com.github.tianzhijiexian:SelectorInjection:1.0.4'
会提示No resource identifier found for attribute 'drawableLeftTint' in package 'kale.selectorinjection'
image
是因为attrs.xml命名为了values.xml的原因吗?
添加attrs中属性到工程的attrs中可以正常使用.

add textcolor

按照你这个思路可以把控件文字不同状态时的颜色也加上

默认开启了水纹在项目中会崩溃

整合进我的项目时候,默认开启了水纹在项目中会崩溃

  • 必须手动在布局文件中将showRipple置为false,才正常使用(跑demo工程没有这个问题)。
  • 布局中设置了android:enabled="true", 也会导致程序崩溃

手机:小米note
miui版本:miui7 6.5.12
android版本:6.0.1

Caused by: android.content.res.Resources$NotFoundException: File res/drawable/item_background_material.xml from color state list resource ID #0x1080457
    at android.content.res.Resources.loadColorStateListForCookie(Resources.java:2800)
    at android.content.res.Resources.loadColorStateList(Resources.java:2749)
    at android.content.res.TypedArray.getColorStateList(TypedArray.java:487)
    at android.graphics.drawable.RippleDrawable.updateStateFromTypedArray(RippleDrawable.java:473)
    at android.graphics.drawable.RippleDrawable.applyTheme(RippleDrawable.java:517)
    at android.content.res.Resources.loadDrawable(Resources.java:2589)
    at android.content.res.MiuiResources.loadDrawable(MiuiResources.java:387)
    at android.content.res.Resources.getDrawable(Resources.java:824)
    at android.content.Context.getDrawable(Context.java:458)
    at kale.injection.SelectorInjection.setSelector(SelectorInjection.java:161)
    at kale.injection.SelectorInjection.injection(SelectorInjection.java:148)
    at kale.ui.view.SelectorTextView.<init>(SelectorTextView.java:25)
    at kale.ui.view.SelectorTextView.<init>(SelectorTextView.java:19)
    ... 30 more
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid color state list tag ripple
    at android.content.res.ColorStateList.createFromXmlInner(ColorStateList.java:217)
    at android.content.res.ColorStateList.createFromXml(ColorStateList.java:201)
    at android.content.res.Resources.loadColorStateListForCookie(Resources.java:2796)
    ... 42 more

shape描边相互影响

    <kale.ui.view.SelectorTextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="0000"
        android:textColor="#333333"
        android:textSize="30sp"
        app:normalColor="@android:color/darker_gray"
        app:normalDrawable="@drawable/btn_oval_shape"
        app:normalStrokeColor="#ff0000"
        app:normalStrokeWidth="2dp" />

    <kale.ui.view.SelectorButton
        android:id="@+id/sstv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_gravity="center_horizontal"
        android:gravity="center"
        android:text="Click Me"
        android:textColor="@android:color/white"
        android:textSize="20sp"
        app:normalColor="#9BD000"
        app:normalDrawable="@drawable/btn_oval_shape" />

第一个Textview的描边和颜色, 在第二个上面也会出现




自动计算按下颜色的一点建议

    protected int getPressedColor(int normalColor) {
        return darken(normalColor, 0.3f);
    }

    public static int darken(final int color, float fraction) {
        return blendColors(Color.BLACK, color, fraction);
    }

    public static int lighten(final int color, float fraction) {
        return blendColors(Color.WHITE, color, fraction);
    }
    /**
     * Blend {@code color1} and {@code color2} using the given ratio.
     *
     * @param ratio of which to blend. 1.0 will return {@code color1}, 0.5 will give an even blend,
     *              0.0 will return {@code color2}.
     */
    public static int blendColors(int color1, int color2, float ratio) {
        final float inverseRatio = 1f - ratio;
        float r = (Color.red(color1) * ratio) + (Color.red(color2) * inverseRatio);
        float g = (Color.green(color1) * ratio) + (Color.green(color2) * inverseRatio);
        float b = (Color.blue(color1) * ratio) + (Color.blue(color2) * inverseRatio);
        return Color.rgb((int) r, (int) g, (int) b);
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.