zoukankan      html  css  js  c++  java
  • view在使用shape属性加圆角的同时,用代码修改其他background属性(例如颜色)不生效

    项目中一个TextView控件设置了shape属性,给其加了圆角,如下:
    1 houlder.mtxtGovernmentType.setBackgroundResource(R.drawable.tv_circular);
    R.drawable.tv_circular的代码如下:
    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
        <corners
            android:bottomLeftRadius="5dp"
            android:bottomRightRadius="5dp"
            android:topLeftRadius="5dp"
            android:topRightRadius="5dp" />
        <solid android:color="#00000000" />
    </shape>
    一个view只能设置一个background,每设置一次Background,另一个Background就会就会被替换掉。
    所以用下面这个GradientDrawable函数来进行多个设置
    1 GradientDrawable myGrad = (GradientDrawable) houlder.mtxtGovernmentType.getBackground();
    2 if (item.getStatus().equals("登记")) {
    3      myGrad.setColor(context.getResources().getColor(R.color.theme_color_primary_light));
    4 } else {
    5      myGrad.setColor(context.getResources().getColor(R.color.zong));
    6  }
    
    
    
     
  • 相关阅读:
    各进制转换
    免root xshell连接termux
    sqlmap怎么拿shell
    SSRF漏洞
    国外安全网站、社区论坛、博客、公司、在线工具等整合收集
    渗透测试常用工具问题总结
    cdn绕过
    xss注入
    永恒之蓝(msf17010)kali复现
    文件上传漏洞和绕过
  • 原文地址:https://www.cnblogs.com/cbx17v/p/6729059.html
Copyright © 2011-2022 走看看