設置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