闹上ImageView的中心位图
题
我有在XML的ImageView的(image_view)和我有布局重力设定为中央和标尺设置成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"/>
解决方案
您可以只使用FrameLayout里解决您的问题。
<强> 强>
其他提示
您ImageView
的layout_width
设置为fill_parent
,所以layout_gravity
不会影响它的父内其水平位置。尝试使用,而不是gravity
layout_gravity
,或wrap_content
代替fill_parent
。
不隶属于 StackOverflow