我在xml中有一個ImageView(image_view),我的佈局引力設置爲居中,並將比例設置爲center_inside ....但是當我將壓縮的bmp傳遞給image_view時,它將它放在屏幕的中間左側(縱向模式)......有關解決方法的任何想法?無法在ImageView上對位圖進行居中
這裏我將它設置爲圖像視圖:
ImageView imageView = (ImageView) findViewById(R.id.image_view);
imageView.setImageBitmap(bitmap565);
我也壓縮它的輸出流:
try {
FileOutputStream fos = new FileOutputStream(filepath);
bitmap565.compress(CompressFormat.JPEG, 90, fos);
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
謝謝大家!
<ImageButton android:id="@+id/ImageButton01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/results" android:layout_gravity="top|center"></ImageButton><ImageView
android:screenOrientation="portrait"
android:layout_width="fill_parent"
android:id="@+id/image_view"
android:layout_gravity="center" android:layout_weight="1.0" android:layout_height="wrap_content" android:scaleType="centerInside"/>
<Button
android:screenOrientation="portrait"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_width="fill_parent" android:textStyle="bold" android:id="@+id/detect_face" android:text="Detect"/>
粘貼XML佈局,請。 – Cristian 2010-11-18 18:55:21
編輯 - 對不起格式不好 – Sapp 2010-11-18 18:57:05
你可以發佈完整的佈局嗎?或者至少,所有的父母?順便說一下ImageViews沒有重力。 – 2010-11-18 21:26:48