我有問題,它適用於平板電腦,但不能在我的手機很好...ImageView的不完全顯示
這裏是預期的輸出(在我的平板電腦) :
這裏是實際輸出(我的電話):
我用繪製試過,效果很好我的手機上。 這裏是我創建位圖,並將其綁定到視圖:
Bitmap srcBmp = BitmapFactory.decodeResource(rcontext.getResources(), R.drawable.portrait);
Bitmap modBmp = Bitmap.createBitmap(srcBmp,0,0,60,60);
((ImageView) view).setImageBitmap(thebmp);
我行佈局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="60px"
android:layout_height="60px"
android:id="@+id/charIcon"
android:src="@drawable/blason" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/charName"/>
</LinearLayout>
我真的不明白爲什麼它這樣做... 我很新到Android,但這是很奇怪
編輯:BLASON只在我的繪製文件夾,它的尺寸爲60×60像素
EDIT2:我USI這個Bitmap.createBitmap(srcBmp,0,0,60,60);因爲我只需要這部分圖像(應顯示整個頭部)。這裏是portrait.png的一部分:
您正在使用** px **。嘗試使用** dp **。它會更好地擴展。 –
如果你在你的可繪製文件夾及其完美尺寸的圖像,那麼爲什麼不設置使用'imageView.setImageResource(R.drawable.blason);' –
dp/px在這裏看起來不是問題。在我的平板電腦上,顯示的是整個頭部,而不是電話上,無論我用於ImageView – Lectem