Android代码设置属性

/设置布局文件的高度,控件为FrameLayout

FrameLayout mFrameLayout = holder.getView(R.id.fl_bill_or_image);
ViewGroup.LayoutParams lp = mFrameLayout.getLayoutParams();
//相当于80dp
lp.height = 115;
mFrameLayout.setLayoutParams(lp);

//获取WRAP_CONTENT属性

LinearLayout.LayoutParams.WRAP_CONTENT

可见:

view.setVisibility(View.VISIBLE);

//设置背景色,控件例子TextVIew

holder.setBackgroundColor(R.id.tv_line, ContextCompat.getColor(getContext(), R.color.lightblue));

//设置Background
ImageView productImage = holder.getView(R.id.iv_product_image);

productImage.setBackground(ContextCompat.getDrawable(getContext(),R.drawable.iv_fillet));

//清除图片资源,控件例子ImageView

productImage.setImageBitmap(null);

//设置图片不显示

productImage.setVisibility(View.GONE);

在代码里利用Strings的字符串 :

BaseApplication.getContext().getString(R.string.dialog_message)

猜你喜欢

转载自blog.csdn.net/a1003434346/article/details/83380262