kaleai / selectorinjection Goto Github PK
View Code? Open in Web Editor NEW一个强大的selector注入器,它可以让view自动产生selector状态,免去了写selector文件的麻烦。
License: Apache License 2.0
一个强大的selector注入器,它可以让view自动产生selector状态,免去了写selector文件的麻烦。
License: Apache License 2.0
大佬, 你好!
ConstraintLayout里面有两个SelectorImageButton, 点击一个另一个也出现点击效果, 要怎么避免这种情况?
按照你这个思路可以把控件文字不同状态时的颜色也加上
手机:小米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
<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的描边和颜色, 在第二个上面也会出现
RT
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);
}
MX4 Pro
Android:5.1.1
水波纹在Android6.0上有显示的Bug,第一次渲染会空白,当第一次点击后,才显示正常。。
引用:https://hk.saowen.com/a/0673cb03a7dc4b3d61d7b0641d60e98abd5e1e47d6f06dcbefd5a18c08cc024c
为什么没有文字的颜色选择器
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.