设置VS组我在XML简单的ImageView:的Nexus 7 - 不同尺寸的图像的代码在XML
<ImageView
android:id="@+id/imgItemFavorites"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/foo"
android:src="@drawable/vote_favorite" />
现在,如果我引用代码视图和做:
ImageView img = (ImageView) llGenericList.findViewById(R.id.imgItemFavorites);
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.vote_favorite, null);
img.setImageBitmap(bitmap);
由于加载的图像较小,因此我的ImageView最终变小了。我认为这与自动缩放有关,这是因为Nexus 7的tvdpi完成的,但任何人都可以告诉我如何以一种不会在其他设备上搞砸的方式来解决这个问题?
根据我的知识,你应该更喜欢设置图像背景,如: android:background =“@ drawable/vote_favorite”试试这个,而不是android.src =“@ drawable/vote_favorite”; – Maulik 2013-03-06 07:07:48
确保您只将hdpi图像放入drawable-hdpi文件夹中,而不是其他任何文件夹。 – Maulik 2013-03-06 07:32:42