[英]Pass drawable image in an ImageView variable
如何将图像从可绘制文件转换为图像视图,因为这将不起作用
ImageView image= R.drawable.pic;
尝试这个
ImageView imageview = findViewById(R.id.imageView);
imageview.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.pic));
尝试这个
ImageView image = new ImageView(this);
image.setImageResource(R.drawable.pic);
要么
ImageView image = new ImageView(this);
image.setImageDrawable(getResources().getDrawable(R.drawable.pic));
尝试这个
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
fab.setImageDrawable(getResources().getDrawable(R.drawable.pic,this.getTheme()));
}else {
fab.setImageDrawable(getResources().getDrawable(R.drawable.pic));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.