【发布时间】:2011-05-12 05:28:25
【问题描述】:
我在 xml 中有一个 ImageView (image_view),我将布局重力设置为 center,比例设置为 center_inside....但是当我将压缩的 bmp 传递给 image_view 时,它会将它放在中间-屏幕左侧(纵向模式)...关于解决方法的任何想法?
这是我将其设置为图像视图:
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 布局。
-
已编辑 - 很抱歉格式不佳
-
你能发布完整的布局吗?或者至少,它的所有父母?顺便说一下,ImageViews 没有重力。
标签: android layout imageview center bmp