代码 shape 背景颜色修改

来源:互联网 发布:linux怎么用vi写入内容 编辑:程序博客网 时间:2024/06/06 04:17
int color=getColor(item.laiBank);// 自定颜色if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {    helper.getView(R.id.rl_content).setBackground(ContextCompat.getDrawable(BankCardActivity.this,R.drawable.shape_top_radius));} else {    helper.getView(R.id.rl_content).setBackgroundDrawable(ContextCompat.getDrawable(BankCardActivity.this, R.drawable.shape_top_radius));}GradientDrawable myGrad = (GradientDrawable)helper.getView(R.id.rl_content).getBackground();myGrad.setColor(color);
//自定义shape  
shape_top_radius
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" >    <corners        android:topLeftRadius="8dp"        android:topRightRadius="8dp"        android:bottomLeftRadius="0dp"        android:bottomRightRadius="0dp"/>    <solid        android:color="#00000000"/></shape>  
0 0
原创粉丝点击