我有在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里解决您的问题。

<强>         

其他提示

ImageViewlayout_width设置为fill_parent,所以layout_gravity不会影响它的父内其水平位置。尝试使用,而不是gravity layout_gravity,或wrap_content代替fill_parent

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top