问题描写叙述 做过android开发基本都遇见过 ViewRootImpl$CalledFromWrongThreadException,上网一查,得到结果基本都是仅仅能在主线程中更改 ui.子线程要改动 ui 仅仅能 post 到主线程或者使用 handler 之类.可是细致看看exception的描写叙述并非这种."Only the original thread that created a view hierarchy can touch its views".仅仅有创建该 v
本文来自网易云社区 作者:孙有军 产品中有一个需求,要求TextView的文字有一个高亮的效果,高亮的同时有跑马灯效果! 本来想在网上找一个现成的用用,比如Facebook出的Shimmer,还有很多,但是都感觉代码太多,因此撸了一个简单版的,talk is cheap,show me you code. 实现 我们知道TextView的文字的颜色是由Paint根据Color控制的,我们可以设置Paint的Shader来实现该效果,这样在TextView绘制的时候Paint会从对应的Shader
最近项目需求,需要获取Textview的行数,通过行数与TextView的maxLines进行比较来确定是否显示TextView下方的展开按钮是否显示,废话少说直接上代码,mTextView.getLineCount() ,似乎很美好,安卓有提供这个方法,但是总是返回0,这是为啥呢?官方注释如下: /*** Return the number of lines of text, or 0 if the internal Layout has not* been built.*/ 也就是说只有内部
2015-07-28 17:29:19 这一篇主要看看布局过程 一.布局过程肯定要不可避免的涉及到layout()和onLayout()方法,这两个方法都是定义在View.java中,源码如下: /** * Assign a size and position to a view and all of its * descendants * * <p>This is the second phase of the layout mechanism. * (The first is measur