Android开发中过时方法总结getColor,singeLine
来源:互联网 发布:王亚林扈华国现状知乎 编辑:程序博客网 时间:2024/06/05 13:21
1、getColor方法在6.0中已经过时:
@ColorInt
@Deprecated
public int getColor(@ColorRes int id) throws NotFoundException {
return getColor(id, null);}
可以参考以下方法:
ContextCompat.getColor(context, R.color.my_color)
This is the source code(源码):
public static final int getColor(Context context, int id) {
final int version = Build.VERSION.SDK_INT;
if (version >= 23) {
return ContextCompatApi23.getColor(context, id);
} else {
return context.getResources().getColor(id);
}}
2、TextView中的singeLine属性过时
可以同时使用line和ellipsize
line控制的是行数,ellipsize控制的是省略号的位置,以及是否跑马灯显示
替换singeline代码如下
android:lines="1"
android:ellipsize="end"
以下为ellipseize属性的一些补充:
“start ”—省略号显示在开头;“end ” ——省略号显示在结尾;”middle”—-省略号显示在中间;”marquee” ——以跑马灯的方式显示(动画横向移动)
3、getDrawable过时
使用
ContextCompat.getDrawable(this, R.mipmap.ic_launcher) 得到Drawable对象
0 0
- Android开发中过时方法总结getColor,singeLine
- Android getColor方法提示过时
- [问题解决]Android中getDrawable和getColor过时的替代方法
- 解决Android中getResources().getColor()方法过时的问题
- Android 6.0 的getColor()方法过时
- Android getResources().getColor() 过时 替代方法
- Android getResources().getColor() 过时 替代方法
- getColor方法在6.0中已经过时
- AndroidStudio getColor方法过时
- getColor过时方法替代
- Android-6.0-23的getColor()过时替代方法
- Android的getColor,getDrawable过时的替代方法
- getResources().getColor()方法过时的替代方法
- getDrawable,getColor 过时的替代方法
- getDrawable,getColor 过时的替代方法
- 过时的getResources().getColor()的替代方法
- getColor过时,setTextColor的现用方法
- getColor()方法过时的解决办法
- 3.Web Service 使用CXF开发客户端
- 【PAT】1090. Highest Price in Supply Chain
- 数据可视化之平行坐标图。
- 【学习笔记之Openlayers3】查询分析篇(第五篇)
- Android 文件的读写
- Android开发中过时方法总结getColor,singeLine
- 使用toolBar作为标题栏并使状态栏透明
- 洛谷 P1164 小A点菜
- 树莓派直接通过网线与电脑相连的方法
- FreeRTOS配置笔记
- hibernate中session的三种状态
- 根据网友资料写的代码频域时域
- The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar
- JAVA中 enum 类型的定义和使用