【发布时间】:2013-08-16 10:09:41
【问题描述】:
我知道这应该很简单,但android:scaleType="centerCrop" 不会裁剪图像
我的图像 1950 像素 宽,需要按照父级的宽度进行裁剪。但是android:scaleType="centerCrop" 不会裁剪图像。我需要在布局中做什么才能仅显示前 400 像素,例如,或者任何屏幕/父宽度是
抱歉,问题很简单 - 尝试用谷歌搜索 - 那里只有复杂的问题。而且我是新人,所以请不要投反对票)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rl1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_color">
<ImageView
android:id="@+id/ver_bottompanelprayer"
android:layout_width="match_parent"
android:layout_height="227px"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:scaleType="matrix"
android:background="@drawable/ver_bottom_panel_tiled_long" />
</RelativeLayout>
如果唯一的方法是通过编程方式裁剪它 - 请给我一个方法的建议
【问题讨论】:
-
你能这样做吗:首先
Bitmap bmp= BitmapFactory.decodeResource(getResources(), R.drawable.ver_bottom_panel_tiled_long);然后bmp = Bitmap.createBitmap(bmp, 0, 0, width, height);ImageView iv = (ImageView)v.findViewById(R.id.ver_bottompanelprayer); if (iv != null) { iv.setImageBitmap(bmp); }。
标签: java android imageview crop