ImageView图像显示为白色方块

时间:2016-03-08 19:58:00

标签: java android imageview

我是新手,无法弄清楚我的图片有什么问题。当我将它们添加到drawable文件夹时,我右键点击了res并选择了New > Image Asset。在预览期间,没有显示4个图像,但仅显示白色框。它们都是100px的正方形图像,格式为.png。我的代码中没有错误,我的应用程序运行没有错误。但ImageView仍然只是一个白色方块,无论我试图显示哪个图像。我不确定我做错了什么,并且不胜感激任何建议。谢谢!

XML:

<ImageView
        android:layout_width="@dimen/imageView"
        android:layout_height="@dimen/imageView"
        android:id="@+id/picImageView"
        android:contentDescription="@string/BMIPicture"
        android:maxHeight="@dimen/imageView"
        android:maxWidth="@dimen/imageView"
        android:minHeight="@dimen/imageView"
        android:minWidth="@dimen/imageView"
        android:layout_alignTop="@+id/answerTextView"
        android:layout_toLeftOf="@+id/maxWeightTV"
        android:layout_toStartOf="@+id/maxWeightTV"
        android:layout_marginTop="@dimen/marginTop" />

在Java中实现ImageView:

bmiPicture = (ImageView) findViewById(R.id.picImageView);
bmiPicture.setImageResource(R.drawable.scale);

0 个答案:

没有答案