مشكلة في توسيط صورة نقطية على صورة Imageview
سؤال
لدي صورة (image_view) في XML ولديّ مجموعة الجاذبية التي تم تعيينها إلى الوسط والمقياس المعين على 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