我有问题,它适用于平板电脑,但不能在我的手机很好...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