Comments (2)
我的设想是作为一个UI库,核心的构成代码是封装的在库中的,不允许外部调用,原因如下:
- 如果类似如loadFromAttribute方法外部可以随意调用,那么需要自定义控件或扩展系统控件时就可以直接在外部扩展,当这样的外部控件逐渐增多的话,UI库的封装就会变的松散且毫无意义。所以只有使用高频的控件才会被封装在库中,方便外部直接使用,而使用低频的控件在外部自己使用ThemeUtils染色即可。
- 一些如loadFromAttribut不允许外部调用的方法,除了处理染色功能外,还缓存了相关染色资源,以便在同一个activity中可以达到染色资源复用,节省性能开销的目的。所以使用频次低的控件可以做直接使用ThemeUtils中的方法直接染色即可(一般的使用频次低的控件资源是单独使用的,不会被其他控件使用)。
- 还有一点是为了便于内部代码的重构优化。如果核心的构成代码暴露给外部调用,当框架重构涉及相关代码时将会变的非常麻烦。如果只在内部调用,那重构就只涉及内部自己的事情了,UI库也可以做到独立的发布。
扩展控件方法:
当在使用过程发现目前封装的系统控件无法满足项目需求时, 你可以:
- 提issue , 我帮你添加支持
- 提一个PR
- 可以自己扩展后打包一个aar内部使用
- 频次低的控件就直接用ThemeUtils即可 (hemeUtils里提供的染色功能已比较齐全)
from magicasakura.
确实不多,tabLayout 一个界面最多一个,手动变色也可以。
from magicasakura.
Related Issues (20)
- TintImageView使用VectorDrawable 设置tint切换主题无法生效问题。 HOT 5
- 可以自定义支持其他组件么? HOT 1
- F ragment 里面的tooloar不会实时刷新 HOT 1
- fragment里面的就没有及时更新。必须重启才有效 HOT 1
- shape文件怎么处理呢 HOT 1
- 我想知道能不能扩展一下。支持drawable HOT 2
- TabLayout不支持 HOT 2
- 对话框不支持alertDialog HOT 1
- 对Databinding 支持不友好。 HOT 1
- 支持WindowManager么? HOT 4
- 添加IntButton在布局的时候报错 HOT 5
- dataBinding在布局添加TintToolbar运行报错 HOT 3
- 升级android studio 3报错 HOT 1
- 依赖方式compile 'com.bilibili:magicasakura:0.1.8@aar'会报错 HOT 1
- 请问如何自定义主题色 HOT 2
- drawableTintMode HOT 5
- 引入库后导致string文件中占位符异常
- android Q适配问题
- About dark mode.
- Java代码中手动设置颜色导致主题切换颜色不刷新问题 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magicasakura.