javanoober / backgroundlibrary Goto Github PK
View Code? Open in Web Editor NEWA framework for directly generating shape through Tags, no need to write shape.xml again(通过标签直接生成shape,无需再写shape.xml)
License: Apache License 2.0
A framework for directly generating shape through Tags, no need to write shape.xml again(通过标签直接生成shape,无需再写shape.xml)
License: Apache License 2.0
暂时发现app:srcCompat 标签的图片会消失, 就是不会显示图片
Drawable drawable = new DrawableCreator.Builder().setCornersRadius(ConvertUtils.dp2px(context.getResources().getDimension(R.dimen.size_level2)))
.setSolidColor(Color.parseColor("#FFFFFF"))
.setStrokeColor(Color.parseColor("#FFFFFF"))
.setStrokeWidth(ConvertUtils.dp2px(2))
.build();
Unable to resolve dependency for ':ZLibrary@debugAndroidTest/compileClasspath': Could not download kotlin-stdlib.jar (org.jetbrains.kotlin:kotlin-stdlib:1.2.70)
库主,这个kotlin语言用到了吗,添加依赖的时候,出错了,如果没有的话,能把依赖库中build.gradle里面的compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"这个去掉吧或者改成implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
测试发现,独立设置水波纹属性无效:
app:ripple_color="#71C671"
app:ripple_enable="true"
而同时设置了下面属性后则有效:
app:unPressed_drawable="#fff"
我昨天在用 px 适配的时候给 button 设置固定宽高和圆角并制定字体大小,字体下面会有部分显示不全,好像被遮盖住了,仔细看能看出来,把 button 换成 textview 就没有这个问题,显示正常
Caused by: java.lang.IllegalStateException: A factory has already been set on this LayoutInflater
at android.view.LayoutInflater.setFactory(LayoutInflater.java:295)
at com.noober.background.BackgroundLibrary.inject(BackgroundLibrary.java:32)
源码对应
public void setFactory(Factory factory) {
if (mFactorySet) {
throw new IllegalStateException("A factory has already been set on this LayoutInflater");
}
if (factory == null) {
throw new NullPointerException("Given factory can not be null");
}
mFactorySet = true;
if (mFactory == null) {
mFactory = factory;
} else {
mFactory = new FactoryMerger(factory, null, mFactory, mFactory2);
}
}
实际上AppCompatActivity中,已经调用过setFactory方法。
所以mFactorySet 为true,重复调用setFactory 就会抛出异常。
建议解决办法:
参考换肤框架SkinCompat中,在调用setFactory 之前将通过反射将mFactorySet值设为false
private void installLayoutFactory(Context context) {
LayoutInflater layoutInflater = LayoutInflater.from(context);
try {
Field field = LayoutInflater.class.getDeclaredField("mFactorySet");
field.setAccessible(true);
field.setBoolean(layoutInflater, false);
LayoutInflaterCompat.setFactory(layoutInflater, getSkinDelegate(context));
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
}
忘采纳
Caused by: java.lang.IllegalStateException: A factory has already been set on this LayoutInflater
at android.view.LayoutInflater.setFactory2(LayoutInflater.java:314)
at com.noober.background.BackgroundLibrary.inject(BackgroundLibrary.java:32)
at com.lai.example.sample.background_library.BackgroundLibraryActivity.onCreate(BackgroundLibraryActivity.kt:12)
at android.app.Activity.performCreate(Activity.java:7060)
at android.app.Activity.performCreate(Activity.java:7051)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
<item name="android:elevation">@dimen/dp2</item>
<item name="bl_corners_radius">@dimen/dp20</item>
<item name="bl_gradient_angle">270</item>
<item name="bl_gradient_startColor">@color/colorBlue2</item>
<item name="bl_gradient_endColor">@color/colorBlue3</item>
<item name="bl_ripple_enable">true</item>
<item name="bl_ripple_color">@color/colorBlue4</item>
想要一个带渐变+阴影+水波纹的效果,但是设置了渐变之后,没有阴影效果,在点击按钮之后,阴影又出现了
implementation的导入是studio3.0的方式,能不能给一下3.0以下compile 的导入方式啊,
看源码,没有用AppCompatDelegate去获取view,但是使用了自定义属性的view就实现了AppCompat,我有点晕,不清楚到底是不是这个库的问题,特来请教
建议在属性上面都加上lib标志,避免冲突
可以使用flag取值的属性来解决?类似于:
app:selector_state = "focus|checked"
在API16以下,没有setColors()和setOrientation()方法,您有好的做法适配吗?
如题
换肤库在Application
里初始化的,本库是在Activity的super.onCreate前调用BackgroundLibrary.inject2(this)
的。
换肤库为 这个。
注释掉换肤库后是正常的。
建议加入默认点击效果,所有控件点击触发透明度改变或缩放,这样不用每个都要配置了,,,或者提供全局控件点击效果配置,这样也方便全局修改, 同意的点赞,,鼓励作者百尺竿头更进一步😄
可以考虑将inject及inject2里的LayoutInflater作为返回值暴露出来,那样在AdapterView/RecyclerView/CustomView等使用时无需再LayoutInflater.from(context)
A factory has already been set on this LayoutInflater
C:/Users/Administrator/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/262e0fab8925583e0d998bdc13acccdb/res/values/values.xml
error: duplicate value for resource 'attr/stroke_color' with config ''.
error: resource previously defined here.
建议下调到14,因为很多app的兼容低版本使用的是14,导致无法使用该库
能不能动态设置里面的属性呢,就比如,在没有输入文字的时候,是白色,输入文字之后,是红色
如题
头疼,要是能预览就好了
环境:根布局是layout,使用了databinding,约束布局
反射修改mFactorySet时,应该使用getDeclaredField方法
if (TextUtils.isEmpty(item.oildesc)) { textView.visibility = View.GONE } else { extView.visibility = View.VISIBLE textView.text = str }
背景框还显示在那
RT,属性名太简单,跟其他第三方的刚好冲突了,建议加上项目标识区分
由于项目中使用了第三方远程依赖包,使用了该包的baseActivity,如何不修改源码的情况 下使用这个框架,测试在newactivity中 inject 和 inject2 都不起作用,ActivityLifecycleCallbacks中也不起作用
请问textView的textColor的selector效果如何配置
AS在自定义属性的时候,名字要和控件一致才会有提示。关键这又不是自定义View,不解决这个问题,好难实用。
报错找不到attr error: style attribute 'app:attr/unPressed_drawable' not found.
styles.xml中是这样的
<style name="btn_main">
<item name="app:unSelected_drawable">@color/colorPrimaryDark</item>
<item name="app:selected_drawable">@color/colorAccent</item>
<item name="app:unPressed_drawable">@color/colorPrimaryDark</item>
<item name="app:pressed_drawable">@color/colorAccent</item>
<item name="app:corners_radius">@dimen/dp10</item>
<item name="android:paddingLeft">@dimen/dp4</item>
<item name="android:paddingRight">@dimen/dp4</item>
<item name="android:background">@drawable/selector_btn_normal_press</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>
系统版本:Android 4.4.4,level 19
设备机型:VIVO Y23L
CPU架构:armeabi-v7a
报错问题:
org.xmlpull.v1.XmlPullParserException
Binary XML file line #1: invalid drawable tag vector com.noober.background.BackgroundLibrary
可以在代码动态设置样式吗?
类BackgroundLibrary中final AppCompatDelegate delegate = ((AppCompatActivity) context).getDelegate();报 Cannot access android.support.v4.view.KeyEventDispatcher.Component的error
Android resource linking failed 就一个很简单的ConstraintLayout 里面放了一个textview
然后设置了一个 app:bl_corner_radius="10dp" 然后就运行不起来...
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.