Android — 透明度 设置

  • TextView 透明度设置
    给TextView文字设置透明度方法
TextView.setTextColor(Color.argb(alpha,34,34,34))

注:RGB与16进制转换链接 http://tool.css-js.com/rgba.html


  • LinearLayout 设置透明度
    如果直接设置LinearLayout透明度会全局共享 把其他布局的透明度也更改了,怎么解决
错误代码示例:
LinearLayout.getBackground().setAlphe(i);
正确代码应该声明当前透明度不共享
LinearLayout.getBackground().mutate().setAlphe(i);

注:i 0~255 透明~不透明

猜你喜欢

转载自blog.csdn.net/u014513456/article/details/53009198