我有以下xml以显示图像。问题是,当页面加载时,图像视图矩形不是按照给定的大小。我该如何纠正它?例如,我需要一个150 x 150矩形的代码。尽管参数正确,但仍显示不正确的图像视图大小
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="2dp"
android:layout_marginTop="2dp"
android:layout_marginRight="2dp"
android:layout_marginBottom="2dp"
android:id="@+id/table_two">
<TableRow
android:padding="2dp"
android:layout_width="150dp"
android:layout_height="150dp">
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_weight="1"
app:srcCompat="@android:drawable/picture_frame"
android:id="@+id/ui_imageView_browse"
android:layout_gravity="center"
android:scaleType="fitXY" />
</TableRow>
</TableLayout>
</LinearLayout>
请注意。检查https://stackoverflow.com/questions/9476662/how-to-set-android-layout-to-support-all-screen-sizes – user8256287
@JaysonJohn,它讲述了不同屏幕尺寸的解决方案。我的问题是关于每个代码的固定大小的矩形,而不考虑屏幕大小或设备。它的工作原理是 – djac